Unofficial Wrapper for OLX API
Project description
OLX Api Wrapper
Simple client for OLX Developer API written in Python
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
About The Project
OLX API Wrapper: Easy Solution for Working with OLX. With this Python library you can quickly fetch user data, handle adverts with simple CRUD operations, and seamlessly integrate with the OLX API. Simplify your development process and focus on building your app hassle-free.
Built With
Getting Started
In order to use OLX Api you nned to sign in at OLX Developer Portal and create an App. More details: https://developer.olx.pl/articles/getting-access-to-api
Prerequisites
To use this API Wrapper you need to copy Client ID and Client Secret. Store them in the safe place. In your code you can use them as enviroment variables, they sholdn't be hardcoded. You can perform actions with API on:
- OLX PL
- OLX BG
- OLX RO
- OLX PT
- OLX UA
- OLX KZ
By default, all requests are sent to olx.PL. To change it you must pass country_code
argument to every child of Olx class, i.e.:
olx.partner.Auth(country_code="bg")
olx.partner.Adverts(country_code="ro")
olx.partner.Users(country_code="pt")
olx.partner.CitiesDistricts(country_code="ua")
olx.partner.AdvertsStatistics(country_code="kz")
# etc...
Installation
- Install
olx-api-wrapper
packagepip install olx-api-wrapper
- In order to get access token you need to authenticate with authorization code. How to get authorization code?
from olx.partner import Auth auth = Auth( client_id="your_client_id", client_secret="your_client_secret", ) auth.authenticate(code='authorization_code') access_token = auth.access_token
- Now you have access token which you will need to have an access to OLX API resources.
Usage
Using olx-api-wrapper
in Your Project
Below are examples demonstrating the usage of olx-api-wrapper
in your project. Please note that you require an access token to execute the actions described below.
Each section from the OLX API documentation corresponds to a separate object within olx-api-wrapper
. For instance, the section Users in the documentation is represented as olx.Users. Additionally, each endpoint mentioned in the documentation corresponds to a single method. For example, the 'Get user' endpoint becomes the method olx.partner.Users().get_user(user_id)
.
If a method returns a value, it will be in the form of a dataclass object. This facilitates ease of use and clarity due to type hints. You can access values as properties, for example, user_values.email
.
This structure provides a convenient and straightforward approach to integrating olx-api-wrapper
into your project.
=====================================
First of all you need to assign an object you want to use to variable and then use available method of this object. You must to pass access_token
to every single object.
Prerequisites: Import olx module.
import olx
- Show authenticated user info
users = olx.partner.Users(access_token='your_access_token') user_info = users.get_authenticated_user() # AuthenticatedUser(id=123, email='john@mail.com', status='confirmed', name='Paweł', phone='123123123', phone_login=None, created_at='2018-01-29 19:48:49', last_login_at='2024-04-26 17:20:48', avatar=None, is_business=True) user_email = user_info.email # john@mail.com
- Get category suggestions for provided ad title
categories_and_attributes = olx.partner.CategoriesAttributes(access_token='your_access_token') suggestions = categories_and_attributes.get_category_suggestions(ad_title='Honda Hornet') # [CategorySuggestion(id='1379', name='Szosowo - Turystyczny', path=[CategoryPath(id='5', name='Motoryzacja'), CategoryPath(id='81', name='Motocykle i Skutery')])]
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!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE
for more information.
Contact
Paweł Stawikowski - pawikoski@gmail.com
Project Link: https://github.com/Pawikoski/olx-api-wrapper
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file olx-api-wrapper-0.3.4.tar.gz
.
File metadata
- Download URL: olx-api-wrapper-0.3.4.tar.gz
- Upload date:
- Size: 20.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e886355c1a4c5a588c44093cb00867b4b8a6069de57b8b01b4559675a2893429 |
|
MD5 | c0f16e3b9d8ddfdd09ce08c31135e96b |
|
BLAKE2b-256 | 44a878ba3809016f130c4328eb2e155a59c314fb394c955444f5a06f3045101b |