Skip to content

Refty/bubble-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bubble-Client

PyPI License Code style

Python client for the Bubble.io APIs

Installation

pip install bubble-client

Examples

  • Get users (or any Bubble thing, really):
>>> from bubble_client import configure, BubbleThing
>>> configure(base_url=..., token=...)

>>> class User(BubbleThing):
...     pass

>>> async for user in User.get():
...     print(user)
User({'name': 'Beatrix Emery', ...})
User({'name': 'Dr. Jekyll', ...})

>>> user.name
'Dr. Jekyll'
  • Change values:
>>> user.name = "Mr. Hyde"
>>> await user.save()
>>> user.name
'Mr. Hyde'
  • Count users:
>>> User.count()
2
  • Add a new user:
>>> user = User(name="Sir Charles Emery")
>>> await user.save()
>>> User.count()
3
  • Search!
>>> constraints = [{'key': 'name', 'constraint_type': 'equals', 'value': 'Mr. Hyde'}]

>>> pet = await Pet.get_one(constraints=constraints)
>>> pet.name
'Mr. Hyde'
  • Join stuff!
>>> class Pet(BubbleThing):
...     pass

>>> pet = await pet.get_one()
>>> await pet.join("created_by", User)

>>> pet.type
'dog'
>>> pet.created_by
User({'name': 'Mr. Hyde', ...})
>>> pet.created_by.name
'Mr. Hyde'
  • Also works on cursors!
>>> async for pet in Pet.get().join("created_by", User):
...     print(pet)
Pet({'type': 'dog', 'created_by': User({'name': 'Mr. Hyde', ...}), ...})
Pet({'type': 'donkey', 'created_by': User({'name': 'Beatrix Emery', ...}), ...})
  • Delete stuff!
>>> constraints = [{"key": "name", "constraint_type": "equals", "value": "Beatrix Emery"}]
>>> pet = await Project.get_one(constraints=constraints)
>>> await pet.delete()

Tips

  • Use asyncio.run(main()) if you are getting a SyntaxError (it means that you can't use async/await in the main body of a Python code).
  • Avoid using dashes in table names (Python object names can't have a dash).
  • The base URL doesn't need the /api/1.1/obj part.

About

🫧 Asynchronous Python client for Bubble.io APIs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages