Skip to main content

Python client for interacting with the OLX API

Project description

PyPI PyPI

OLX Python Client (py-olx-client)

py-olx-client is a Python client library for interacting with the OLX API. It provides an easy way to interact with the OLX platform, allowing you to manage users, ads, and more.

Features

  • Retrieve user information
  • Get ad details
  • Get contact numbers for ads
  • Token management (refresh)

Installation

You can install the library via pip:

pip install py-olx-client

1. Initialize the OLX Client

You need an OLX API access token to authenticate. Once you have the token, initialize the OLX class.

from py_olx import OLX

# Replace with your actual access token
access_token = "your_access_token"
olx = OLX(access_token)

2.Retrieve Authenticated User

You can retrieve the details of the currently authenticated user.

# Fetch authenticated user details
user_details = olx.user.get_authenticated_user()
print(user_details)

3. Retrieve User by ID

To retrieve information about a user by their user ID:

user_id = 12345  # Replace with the user ID
user_info = olx.user.get_user(user_id)
print(user_info)

4.Working with Ads

Get Advertisement by ID To retrieve details about a specific ad by its ID:

ad_id = 123456  # Replace with the ad ID
ad_details = olx.ads.get_ad(ad_id)
print(ad_details)

5.Get Contact Number for an Advertisement

To retrieve the contact number for a specific advertisement:

contact_number = olx.ads.get_contact_number(ad_id)
print(contact_number)

6.Refreshing Token

You can refresh the token using the OLXAuth class. Here is an example of refreshing the token:

from py_olx import OLXAuth

# Replace with the client ID, client secret, and the refresh token you got during initial auth
client_id = "your_client_id"
client_secret = "your_client_secret"
refresh_token = "your_refresh_token"

auth = OLXAuth(client_id, client_secret,refresh_token)
new_access_token = auth.refresh_token()
print(f"New Access Token: {new_access_token}")

Future Features

  • Posting, Editing, and Deleting Ads: Implement functionality to post, edit, and delete ads.
  • Search Ads by Category: Add search functionality based on categories and filters.
  • Retrieve and Clear Statistics: Fetch and reset ad statistics.
  • Respond to Messages: Add support for responding to messages related to ads.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_olx_client-0.0.3.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_olx_client-0.0.3-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file py_olx_client-0.0.3.tar.gz.

File metadata

  • Download URL: py_olx_client-0.0.3.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for py_olx_client-0.0.3.tar.gz
Algorithm Hash digest
SHA256 c9f8cd66d4719b1cd75801a9bbcbae6f6f1e38bc5e0d83ddd95eedafce60640d
MD5 1d8c23173e1aaeebe2d6fcb87d1e7e8e
BLAKE2b-256 5fe2a6c0eb1ae8c8109260ed4488e67bfc6071cfbfd3c3f6f0c6525830df3f5e

See more details on using hashes here.

File details

Details for the file py_olx_client-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: py_olx_client-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.5

File hashes

Hashes for py_olx_client-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7b23efa1415c73b3192139cc56e0560d919695583d00d140f1d273b922e38239
MD5 94f0195f8391661cd45f667ae347d70c
BLAKE2b-256 5dcd231a5b5c8d49af58dcc3433346424323a88dfc6ec2982408ed86e6358bb3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page