Socket
Book a DemoInstallSign in
Socket

medium-wrapi

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

medium-wrapi

Wrapper for Medium REST API

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

Medium API Wrapper

Client interface for accessing Medium API.

Usage

Create a client object to connect to Medium API endpoints.

var mediumWrapi = require('medium-wrapi');

var client = new mediumWrapi("v1", API_BEARER_TOKEN));

// Now you are ready to make API calls to medium.

Provide parameters and a callback.

API calls follow this syntax:

client.action(param1, ..., callback);

  • param - (as required) url parameters - eg: For publications the value for {{userId}} .

Examples

Getting the authenticated user's details

client.user(function(err, data) {
  if (!err) {
    console.log(data);
  }	
});

Listing the user's publications

client.publications("5303d74c64f66366f00cb9b2a94f3251bf5", 
  function(err, data) {
    if (!err) {
      console.log(data);
    }	
  }
);

Fetching contributors for a publication

client.contributors("b45573563f5a", function(err, data) {
  if (!err) {
    console.log(data);
  }	
});

Creating a post

client.posts("5303d74c64f66366f00cb9b2a94f3251bf5",
  {
    "title": "Liverpool FC",
    "contentFormat": "html",
    "content": "<h1>Liverpool FC</h1><p>You’ll never walk alone.</p>",
    "canonicalUrl": "http://jamietalbot.com/posts/liverpool-fc",
    "tags": ["football", "sport", "Liverpool"],
    "publishStatus": "public"
  },
	function(err, data) {
	  if (!err) {
	    console.log(data);
	  }	
	}
);

Creating a post under a publication

client.publication.post("b45573563f5a",
  {
    "title": "Hard things in software development",
    "contentFormat": "html",
    "content": "<p>Cache invalidation</p><p>Naming things</p>",
    "tags": ["development", "design"],
    "publishStatus": "draft"
  },
  function(err, data) {
    if (!err) {
      console.log(data);
    } 
  }
);

Uploading an image

client.images(
  {
    formData: {
      custom_file: {
        value:  fs.createReadStream('/path/to/myimage.png'),
        options: {
          filename: 'lenticular.png',
          contentType: 'image/png'
        }
      }
    }
  }, 
  function(err, data) {
    if (!err) {
      console.log(data);
    } 
  }
);

API Functions

Users

Publications

Posts

Images

License

MIT

Keywords

medium

FAQs

Package last updated on 08 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts