This release is a pre-release and may not be stable for production use.
A thoroughly typed Python client for the Openverse API.
Installation
pip install openverse-api-client
Usage
The Openverse API client has a single external dependency on httpx. HTTPx was chosen because the precense of both a synchronous and asynchronous HTTP client from a single library, with nearly identical APIs, made it easy to generate the Python client using the generator.
from openverse_api_client import OpenverseClient, AsyncOpenverseClient
with OpenverseClient() as openverse:
images = openverse.GET_v1_images(
q="dogs",
license="by-nc-sa",
source=["flickr", "wikimedia"],
)
with AsyncOpenverseClient() as async_openverse:
audio = await async_openverse.GET_v1_audio(
q="birds",
license="by",
source=["freesound"],
)
Using the Openverse client as context managers will automatically close the underlying HTTPx client. Call close on the Openverse client to manually close the underlying HTTPx client when not using the context manager.
Authentication
By default, the clients will make unauthenticated requests. Pass client_id and client_secret to the client constructor to authenticate requests. The client automatically handles requesting tokens and token expiration.
from openverse_api_client import OpenverseClient
# The same API applies to the async client
authenticated_openverse = OpenverseClient(
client_id="...",
client_secret="...",
)
Alternative Openverse API instances
The clients reference the official production Openverse API instance by default, https://api.openverse.engineering. If you would like to send requests to a different API instance, pass base_url to the constructor:
from openverse_api_client import OpenverseClient
# The same API applies to the async client
localhost_openverse = OpenverseClient(
base_url="localhost:50280",
)
Development
Please refer to the repository README
License
openverse-api-client is distributed under the terms of the GNU Lesser General Public License v3.0 or later license.
Release files for openverse-api-client 0.0.1a3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| openverse_api_client-0.0.1a3.tar.gz | 15.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openverse_api_client-0.0.1a3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:40.2 kB
Release files / openverse_api_client-0.0.1a3.tar.gz
| Download URL | openverse_api_client-0.0.1a3.tar.gz |
|---|---|
| Size | 15.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0312caea94bdc6b988e02260295647817541f1f12620e5a15b7cab1083135fc6
|
|
BLAKE2b-256 checksum How to use checksums |
e001bca05836f500f73bb1003b84d39567fcd49917129dca990f6d2dac9568f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.8
|
Release files / openverse_api_client-0.0.1a3-py3-none-any.whl
| Download URL | openverse_api_client-0.0.1a3-py3-none-any.whl |
|---|---|
| Size | 24.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
35ef571dcb0acfd3787f1762a846091b3abdd50b4489ca0388360d2dc5a160f8
|
|
BLAKE2b-256 checksum How to use checksums |
858047396d7d65b1661dd986e204bb3bc099a6484122e4aa4729489c0eb074cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.8
|