npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

meli

v1.0.2

Published

A Mercado Libre SDK client that supports promises

Downloads

3

Readme

Meli

Mercado Libre SDK for Node.js that supports promises.

Install

npm install meli

Use

require:

var meli = require('meli');

Constructor:

var meliObject = new meli.Meli(client_id, client_secret, [access_token], [refresh_token]);

|Field|Type|Required|Description| |-----|----|--------|-----------| |client_id|int|yes|ID provided when creating a MELI APP (link to create app guide)| |client_secret| string| yes| Hash string key provided when creating a MELI APP (link to create app guide)| |access_token |string| optional| Used to talk to our API resources that require credentials (eg: POST to /items).| |refresh_token| string| optional| Hash string provided when a user authorizes an A P. Used to get a new valid access_token (only available when offline_access scope in APP settings is checked).|

Authorization methods

getAuthURL

meliObject.getAuthURL(redirect_uri)

|Field|Type|Required|Description| |-----|----|--------|-----------| redirect_uri|string|yes|Callback URL to which the user will be redirected after granting permission to the Meli APP. The code required to obtain the first access_token (required in Authorize method) will be appended to this URL when making this redirect.| returns string

authorize

meliObject.authorize(code, redirect_uri) 

|Field|Type|Required|Description| |-----|----|--------|-----------| code|string|yes|Code received at redirect_uri when user granted permission to the Meli APP.| redirect_uri|string|yes|Callback URL to which the API will send the access & refresh tokens. Must be the same as the one configured in the Meli APP settings.|

refreshAccessToken

meliObject.refreshAccessToken() 

Request methods

get

meliObject.get(path, [params,]) 

|Field|Type|Required|Description| |-----|----|--------|-----------| path|string|yes|API resource path to which the GET request will be sent to.| params|object|optional|Additional params (if required).|

Examples
//Get categories from mercado libre argentina
meliObject.get('sites/MLA/categories').then(res => {
    /** returns:
		res = [ 
				{ id: 'MLA5725', name: 'Accesorios para Vehículos' },
				{ id: 'MLA1071', name: 'Animales y Mascotas' },
				{ id: 'MLA1367', name: 'Antigüedades' },
				{ id: 'MLA1368', name: 'Arte y Artesanías' },
				{ id: 'MLA1743', name: 'Autos, Motos y Otros' },
				{ id: 'MLA1384', name: 'Bebés' },
				...
			]
	*/
});
//Get users with ids 145925943 and 145925951
meliObject.get('users', {
    ids: [145925943, 145925951]
}).then(res => {
   /** returns:
		res = [ 
				{ 
					id: 145925943,
				    nickname: 'TETE2780570',
				    registration_date: '2013-09-17T14:20:30.000-04:00',
				    country_id: 'AR',
				    address: { state: 'AR-C', city: 'Palermo' },
				    user_type: 'normal',
				    tags: [ 'normal', 'test_user', 'user_info_verified' ],
				    logo: null,
				    points: 100,
				    site_id: 'MLA',
				    permalink: 'http://perfil.mercadolibre.com.ar/TETE2780570',
				    seller_reputation:
				     { level_id: null,
				       power_seller_status: null,
				       transactions: [Object] },
				    buyer_reputation: { tags: [] },
				    status: { site_status: 'deactive' } 
				},
				{
					id: 145925951,
				    nickname: 'TETE1341752',
				    registration_date: '2013-09-17T14:20:43.000-04:00',
				    country_id: 'AR',
				    address: { state: 'AR-C', city: 'Palermo' },
				    user_type: 'normal',
				    tags: [ 'normal', 'test_user', 'user_info_verified' ],
				    logo: null,
				    points: 100,
				    site_id: 'MLA',
				    permalink: 'http://perfil.mercadolibre.com.ar/TETE1341752',
				    seller_reputation:
				     { level_id: null,
				       power_seller_status: null,
				       transactions: [Object] },
				    buyer_reputation: { tags: [] },
				    status: { site_status: 'deactive' } 
				}
			]
	*/
});

post

meliObject.post(path, body, [params,]) 

|Field|Type|Required|Description| |-----|----|--------|-----------| path|string|yes|API resource path to which the POST request will be sent to.| body|object|yes|Body to be sent when executing the POST request. params|object|optional|Additional params (if required).|

upload (post with multipart)

meliObject.upload(path, body, [params,]) 

|Field|Type|Required|Description| |-----|----|--------|-----------| path|string|yes|API resource path to which the POST request will be sent to.| body|object|yes|Body to be sent when executing the POST request. params|object|optional|Additional params (if required).|

put

meliObject.put(path, body, [params,]) 

|Field|Type|Required|Description| |-----|----|--------|-----------| path|string|yes|API resource path to which the PUT request will be sent to.| body|object|yes|Body to be sent when executing the PUT request. params|object|optional|Additional params (if required).|

delete

meliObject.delete(path, [params,]) 

|Field|Type|Required|Description| |-----|----|--------|-----------| path|string|yes|API resource path to which the DELETE request will be sent to.| params|object|optional|Additional params (if required).|

Details necessary

In all cases the response is a Promise.

The object passed in the params parameter in functions get, post, put and delete. Is automatically converted to a query string

Example:

meliObject.get('/users/', {ids: [77169310, 1231233]})
.then(body => console.log(body))
.catch(error => console.error(error));

The request is get ​​to the following address:

https://api.mercadolibre.com/users/?ids=77169310,1231233