• This repository has been archived on 10/Feb/2022
  • Stars
    star
    129
  • Rank 278,277 (Top 6 %)
  • Language
    Python
  • Created over 11 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

MercadoLibre's Python SDK

No longer maintained

[DEPRECATED] This repository is no longer maintained

From the first week of April 2021 we will stop maintaining our SDKs.

This project is not functional, the dependencies will not be updated to latest ones.

We recommend you read our documentation.

Mercado Libre Developers

Mercado Libre Developers

MercadoLibre's Python SDK

This is the official Python SDK for MercadoLibre's Platform.

Requirements.

Python 2.7 and 3.4+

Installation

pip install

If the python package is hosted on a repository, you can install directly using:

pip install git+https://github.com/mercadolibre/python-sdk.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/mercadolibre/python-sdk.git)

Then import the package:

import meli

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import meli

Usage

# Auth URLs Options by country

# 1:  "https://auth.mercadolibre.com.ar"
# 2:  "https://auth.mercadolivre.com.br"
# 3:  "https://auth.mercadolibre.com.co"
# 4:  "https://auth.mercadolibre.com.mx"
# 5:  "https://auth.mercadolibre.com.uy"
# 6:  "https://auth.mercadolibre.cl"
# 7:  "https://auth.mercadolibre.com.cr"
# 8:  "https://auth.mercadolibre.com.ec"
# 9:  "https://auth.mercadolibre.com.ve"
# 10: "https://auth.mercadolibre.com.pa"
# 11: "https://auth.mercadolibre.com.pe"
# 12: "https://auth.mercadolibre.com.do"
# 13: "https://auth.mercadolibre.com.bo"
# 14: "https://auth.mercadolibre.com.py"

# For example in your app, you can make some like this to get de auth
import urllib

params = urllib.urlencode({'response_type':'code', 'client_id':'your_client_id', 'redirect_uri':'your_redirect_uri'})
f = urllib.urlopen("https://auth.mercadolibre.com.ar/authorization?%s" % params)
print f.geturl()

his will give you the url to redirect the user. You need to specify a callback url which will be the one that the user will redirected after a successfull authrization process.

Once the user is redirected to your callback url, you'll receive in the query string, a parameter named code. You'll need this for the second part of the process

Examples for OAuth - get token

from __future__ import print_function
import time
import meli
from meli.rest import ApiException
from pprint import pprint
# Defining the host, defaults to https://api.mercadolibre.com
# See configuration.py for a list of all supported configuration parameters.
configuration = meli.Configuration(
    host = "https://api.mercadolibre.com"
)


# Enter a context with an instance of the API client
with meli.ApiClient() as api_client:
# Create an instance of the API class
    api_instance = meli.OAuth20Api(api_client)
    grant_type = 'authorization_code' # str
    client_id = 'client_id_example' # Your client_id
    client_secret = 'client_secret_example' # Your client_secret
    redirect_uri = 'redirect_uri_example' # Your redirect_uri
    code = 'code_example' # The parameter CODE
    refresh_token = 'refresh_token_example' # Your refresh_token

try:
    # Request Access Token
    api_response = api_instance.get_token(grant_type=grant_type, client_id=client_id, client_secret=client_secret, redirect_uri=redirect_uri, code=code, refresh_token=refresh_token)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling OAuth20Api->get_token: %s\n" % e)

Example using the RestClient with a POST Item

from __future__ import print_function
import time
import meli
from meli.rest import ApiException
from pprint import pprint
# Defining the host, defaults to https://api.mercadolibre.com
# See configuration.py for a list of all supported configuration parameters.
configuration = meli.Configuration(
    host = "https://api.mercadolibre.com"
)


# Enter a context with an instance of the API client
with meli.ApiClient() as api_client:
    # Create an instance of the API class
    api_instance = meli.RestClientApi(api_client)
    resource = 'resource_example' # A resource like items, search, etc
    access_token = 'access_token_example' # Your access token

    # A body example to post a item in Argentina
    body = {
      "title": "Item de test - No Ofertar",
      "category_id": "MLA5991",
      "price": "350",
      "currency_id": "ARS",
      "available_quantity": "12",
      "buying_mode": "buy_it_now",
      "listing_type_id": "bronze",
      "condition": "new",
      "description": "Item de Teste. Mercado Livre SDK",
      "video_id": "RXWn6kftTHY",
      "pictures": [
        {
          "source": "https://http2.mlstatic.com/storage/developers-site-cms-admin/openapi/319968615067-mp3.jpg"
        }
      ],
      "attributes": [
        {
          "id": "DATA_STORAGE_CAPACITY",
          "name": "Capacidad de almacenamiento de datos",
          "value_id": "null",
          "value_name": "8 GB",
          "value_struct": {
            "number": 8,
            "unit": "GB"
          },
          "values": [
            {
              "id": "null",
              "name": "8 GB",
              "struct": {
                "number": 8,
                "unit": "GB"
              }
            }
          ],
          "attribute_group_id": "OTHERS",
          "attribute_group_name": "Otros"
        }
      ],
      "variations": [
        {
          "price": 350,
          "attribute_combinations": [
            {
              "name": "Color",
              "value_id": "283165",
              "value_name": "Gris"
            }
          ],
          "available_quantity": 2,
          "sold_quantity": 0,
          "picture_ids": [
            "882629-MLA40983876214_032020"
          ]
        }
      ]
    }

    try:
        # Resourse path POST
        api_response = api_instance.resource_post(resource, access_token, body)
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling RestClientApi->resource_post: %s\n" % e)

Documentation & Important notes

The URIs are relative to https://api.mercadolibre.com
The Authorization URLs (set the correct country domain): https://auth.mercadolibre.{country_domain}
All docs for the library are located here
Check out our examples codes in the folder examples
Don’t forget to check out our developer site

More Repositories

1

chico

A collection of easy-to-use UI components.
JavaScript
342
star
2

php-sdk

MercadoLibre's PHP SDK
PHP
184
star
3

golang-restclient

An extremely simple to use, lightweight, yet powerful REST Client
Go
149
star
4

net-sdk

MercadoLibre's .NET SDK
C#
56
star
5

mercadolibre.js

MercadoLibre API Client
49
star
6

java-sdk

MercadoLibre's Java SDK
Java
46
star
7

java-restclient

A lightweight REST client implementation for Java 1.7+.
Java
36
star
8

cacique

mercadolibre's Cacique is a automation test tool distribuited under gpl licence. BETA Version
JavaScript
32
star
9

flamepool

Go
30
star
10

polp-fiction-metrics

polp-fiction-metrics
Python
28
star
11

fury-core-ci

Github actions for Fury Core applications
TypeScript
27
star
12

ruby-sdk

MercadoLibre's Ruby SDK
Ruby
24
star
13

meli-card-drawer-ios

Meli Card Drawer iOS - Shared credit card UI component
Swift
22
star
14

mobile-dependencies_whitelist

Whitelist dependencies files for mobile teams
Ruby
22
star
15

golang-sdk

MercadoLibre's Golang SDK
Go
22
star
16

meli-card-drawer-android

Meli Card Drawer Android - Shared credit card UI component
Kotlin
19
star
17

nodejs-sdk

JavaScript
18
star
18

MPTopFloatingView

Objective-C
17
star
19

toiler

Toiler is a AWS SQS long-polling thread-based message processor.
Ruby
16
star
20

ubatch

uBatch is a simple, yet elegant library for processing streams data in micro batches.
Python
15
star
21

tiny.js

A JavaScript utility library oriented to real world tasks
JavaScript
13
star
22

piper

A minimal pipeline library for golang
Go
11
star
23

workshop-docker-fullstack2017

workshop-docker-fullstack2017
CSS
11
star
24

MPDynamicSkeleton

Modularized skeleton with gradient animation
Swift
10
star
25

assimilator

A Restful JSON API that controls policies and routes from different firewall brands.
Python
9
star
26

cx-frontend-challenge

JavaScript
9
star
27

payment-methods-component

CSS
9
star
28

workshop-docker

Meli Docker Workshop
JavaScript
8
star
29

arcanist-extensions

PHP
8
star
30

resilience-workshop-api

Java
8
star
31

mlbusiness-components-ios

Shared Business UI components
Swift
7
star
32

java-circuit-breaker

Circuit breaker for Java 1.7+.
Java
7
star
33

fury_mobile-ios-ui

Objective-C
6
star
34

seamless-iframe

A fallback that emulates the main features of the seamless iframe.
JavaScript
6
star
35

flexbuffer-node

Node based library that gives you a variety of options for buffer optimization.
JavaScript
6
star
36

card-form-android

Kotlin
5
star
37

workshop_python_brasil_2021

HTML
4
star
38

fury-little_monster-gem

Ruby
4
star
39

card-form-ios

Swift
4
star
40

HadoopCryptoCompressor

Crypto compressor for hdfs that enable to compress with public key any file into hdfs
Java
4
star
41

java-metrics

This interface helps you to collect, measure and record metrics in Java applications
Java
4
star
42

srt

Python
3
star
43

java-sdk-repo

MercadoLibre's Java SDK Maven Repository
2
star
44

MLDynamicModal

Custom modal for iOS with swipe, tap and button dismiss recognizer
Objective-C
2
star
45

productidentifiers-frontend-demo

CSS
2
star
46

mlbusiness-components-android

Java
2
star
47

grails-esi

An ESI plugin for grails
Groovy
2
star
48

java-json

A Json interface for Java applications
Java
2
star
49

point-mainapp-demo-android

Kotlin
1
star
50

fury_device-sdk-ios

Swift
1
star
51

presentacion-plataformas-lenguajes-web

JavaScript
1
star
52

curso_ios_lp

curso ios - ejercicios
Objective-C
1
star