Skip to content

Ryotess/PyOpenverse

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIT License LinkedIn


Logo

PyOpenverse-- A Python image/audio search engine base on Openverse

This is an un-official Python package built with Openverse API, currently we only provide image search api in this beta version. The audio search api will be updated in near future.
Explore the docs »

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact
  7. Acknowledgments

About The Project

Built With

Python

(back to top)

Getting Started

Please follow the instructions to install and set up the environment for this project.

Installation

  1. Clone the repo
    git clone https://github.com/Ryotess/PyOpenverse.git
  2. Move to the project
    cd ./PyOpenverse
  3. Build environment
    pip install -r requirements.txt

(back to top)

Quick Start

You can follow the sample code to get the sample usage of this package.

Usage

Setup

How to use this package in your own project?

You can directly copy the folder pyopenverse to your project, here is an example structure design:

.
└── your-project/
    ├── your_custom_module/
    │   ├── your_function_1.py
    │   └── your_function_2.py
    ├── PyOpenverse/   <--- Copy & Paste the entire pyopenverse folder here.
    │   ├── auth.py
    │   ├── config.py
    │   └── engine.py
    └── your_main.py

Set Credential

If you already have a credential of Openverse API, please put your credential into an .env file with keys OPENVERSE_CLIENT_ID and OPENVERSE_CLIENT_SECRET before the following instruction

Get Credentials (Optional)

If you don't have a credential of Openverse API, we provide an function for you to get your own API's id and secret key.

# import packages and create a pyopenverse engine
from pyopenverse.engine import PyOpenverse

openverse = PyOpenverse()
# Register for API access if not already registered
name = "My amazing project"
description = "To access Openverse API"
email = "user@example.com"
openverse.register(name, description, email)

This method creates a credential for you(and also create a .env file in the work directory) and loads it into the engine, thus you can use the engine without insert the credential info again.

Create a PyOpenverse Engine

# import packages and create a pyopenverse engine
from pyopenverse.engine import PyOpenverse

openverse = PyOpenverse()

The engine loads the creadential from the .env file you just created.
If you don't want to use .env file, you can also insert the creadential by the following code

openverse = PyOpenverse(client_id="your_client_id", client_secret="your_client_secret")

Search

Now we can use this engine to search images by query (currently only support image search api)

query = "sunset" # Please change the query into what you wanna search
image_urls = openverse.img_search(query=query) # This will return a list of URL of images

API Info

Moreover, you can also check the information (ex. status, usage,...) of your account by using get_info()

# Check API information
openverse.get_info()

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the Apache 2.0 License. See LICENSE.txt for more information.

(back to top)

Contact

E-Mail: jessforwork2023@gmail.com

Project Link: https://github.com/Ryotess/PyOpenverse

(back to top)

References

(back to top)