Skip to main content

Mercado Libre API Client (unoffical)

Project description

Mercado Libre Python API Client (unoffical)

This client is developed and maintened by Mercado Radar.

If you have improvements or suggestions, feel free to open a Pull Request on https://github.com/mercadoradar/mercadolibre-client

First Steps

Set your app configuration in environment variables as follows:

MERCADO_LIBRE_APP_CLIENT_ID  
MERCADO_LIBRE_APP_CLIENT_SECRET
MERCADO_LIBRE_REDIRECT_URI  

Authentication

  1. Browse to `http://auth.mercadolibre.com.ar/authorization?response_type=code&client_id={MERCADO_LIBRE_APP_CLIENT_ID}&redirect_uri={MERCADO_LIBRE_REDIRECT_URI}
  2. Pass the query param code to the OAuth().authenticate() method
from mercadolibre.OAuth import OAuth

...

response = OAuth().authenticate(code=code)
  1. This will return you an access_token and refresh_token that should be managed and stored by your application

  2. To private requests you should always include the access_token and refresh_token when initiate the MercadoLibreAPI

self.mercadolibre = MercadoLibreAPI(access_token=access_token,
                                    refresh_token=refresh_token)

self.mercadolibre.Item().get(id="MLB123456789")
  1. The client will try to make the private request with the given access_token.

    • If it fails because of token expired, it will try to update the token for you using the refresh_token provided

    • If it fails again, then it will return error

    • If there is no need to update the access_token it will return tokens = None so you don't need to update nothing

  2. If the client get a new token, it will be returned to you along with the request response as below:

self.mercadolibre = MercadoLibreAPI(access_token=access_token,
                                    refresh_token=refresh_token)

response, tokens = self.mercadolibre.Item().get(id="MLB123456789")

Public Requests

  1. Do not need an access_token and refresh_token
MercadoLibreAPI().Item().get(id="MLB123456789")

Private Requests

Requests that need authentication, mandatory access_token and refresh_token

access_token: string

refresh_token: string

from mercadolibre import MercadoLibreAPI

...

self.mercadolibre = MercadoLibreAPI(access_token=access_token,
                                    refresh_token=refresh_token)

self.mercadolibre.Item().get(id="MLB123456789")

...

Resources

Items

Create Item Item().create(data)

data: dict

 

Get Item By Id: Item().get(id)

id: string

 

Multi-get Items By Id: Item().Item(id)

ids: list of string

 

Get item description: Item().get_description(id)

id: string

 

Update: Item().update(id, data)

id: string

data: dict

 

Update Description: Item().update_description(id, description)

id: string

description: string

 

Orders

Get Order By Id: Order().get(id)

id: string

 

Questions

Get Question By Id: Question().get(id)

id: string

 

Want to contribute?

Feel free to code and open a Pull Request.

Licence

MIT License

Copyright (c) 2021 Mercado Radar

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

mercadolibre-client-0.0.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

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

mercadolibre_client-0.0.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file mercadolibre-client-0.0.1.tar.gz.

File metadata

  • Download URL: mercadolibre-client-0.0.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for mercadolibre-client-0.0.1.tar.gz
Algorithm Hash digest
SHA256 3b4929b848565464a378c61861fb7f1f927792529361fecf2e90830dba1c7ae3
MD5 bce9b6070986331f523b0ef4869ed035
BLAKE2b-256 2f16133e34c2b0bbb05fb215a0a44cff56cd7d374fc5eda18bcdafec926cb156

See more details on using hashes here.

File details

Details for the file mercadolibre_client-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: mercadolibre_client-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.10

File hashes

Hashes for mercadolibre_client-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 29b3ae297ae5ebd835dc0da0304aa8124551389eba68e1367dc2311413f1ed56
MD5 d00a9dc7ec7d0bbb1feafa07f62fce13
BLAKE2b-256 38e5091b7529def0e0fa5aa9341732169f832d6ef3cdd82c8699309349a488a1

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