Can Panda3d recieve data from an API?

Hey!

I wanted to know if Panda3D allows data to be received/sent through an API (to connect to a database, for example). That’s a key component of my project, so it would be nice to know that before going on.

Thank you in advance!

I don’t think that Panda has much say in the matter: if you have your data in Python, you should be able to send it to anywhere that the relevant APIs allow.

Oh really? Can I do anything I’d normally be able to do in a Python application not using Panda3D? I thought that engines had some sort of restrictions. Like, can I use other APIs that are not listed in the Panda3D APIs list? Sorry, I’m quite new to this haha.

1 Like

My understanding is that any external Python module you have installed via pip is also available to you in your Panda3D Python scripts.

So if you wanted to, for example, use the Beautiful Soup library to scrape data from websites, you would just import it in your Panda3D Python code like any other module, assuming you already installed it via pip.

Pretty much, yes, I do believe.

I think that it depends somewhat on the engine.

The main such restriction that I’d expect comes from the fact that some engines specify their own internal programming-language, which naturally restricts what third-party tools might be available.

But Panda is not such an engine: it just uses Python (and C++), and so things that can be done in Python can in general be done in Python when using Panda. (And likewise with C++.)

(There might be things that don’t interact well with Panda–but that’s normal when bringing multiple packages together, and not specific to game-engines, I daresay.)

Of course! :slight_smile:

For example, I believe that there are some people who use alternative GUI modules, or who use “numpy”.

I see nothing to be sorry for! We don’t know (most) things until we learn them, one way or another, after all. :slight_smile:

1 Like

I think the main thing to consider with this is that whatever library you are using to access the API can do so asynchronously, ie. in the background, and not block the main loop.

Otherwise, you need to use threading or multiprocessing so that you don’t block the rendering loop while you are making the API request.

1 Like

Oh I see! Where can I read more about it? I don’t know yet how to do things asynchronously in Panda3d :grimacing:

Try to re-frame your mind and think of panda as a suite of python libraries for rendering, collisions, etc. Genuinely, if you can do it in python, you can do it in panda. Inckuding using any of the other python packages. So to answer your specific question, the answer is absolutely. You could sockets programming, high level protocols like http, you could even choose to use an ORM like sql alchemy for your db access.

To follow up what other have said regarding not blocking the main loop. You have options! You could do multiprocess programming, this is essentially what intervals are! You could do threading (with some python limitstions), you could do coroutines with async io. So how to do it depends on your goals. If you want to tell me more about what you need i could point you further in the right direcrtion. If its legit just database, id say go with sql lite and async io. Here is a library for that.

Cheers and welcome.