Using the Medium.com API with JSON-AI
2 min readNov 2, 2018
A node server should be able to get the title of this document, and this first paragraph of text from this Medium article using Medium.com’s api. This node server then needs to put the information from Medium.com’s api into this exact JSON-AI format.
{
“@i.document": {
"medium": {
"url":"https://medium.com/p/8f44217e6c08",
"body": {
"title": "Using the Medium.com API with JSON-AI",
"content": [
{
"paragraph": "A node server should be able to get the title of this document, and this first paragraph of text from this Medium article using Medium.com's api. This node server then needs to put the information from Medium.com's api into this exact JSON-AI format."
}
}
}
}
STEP 1:
Let’s create a node server that can connect to Medium.com
In my example I will be using the Express application generator, which can be found below.
In your terminal:
You are going to use the express generator to install a node server called medium.
$ cd express install medium
$ cd medium
You should see the following message upon successful install:
install dependencies:
$ cd install && npm install
run the app:
$ DEBUG=install:* npm startGo ahead an go into the install directory an install the package.json files.$ cd install
$ npm installIn my bin/www.js file I change my port to 1235, so that it doesn't interfere with other services.var port = normalizePort(process.env.PORT || '1235');
In JSON.AI the @i.agent.Medium.req.port = "1235"!