Skip to content
Harry Rybacki edited this page Jun 10, 2013 · 3 revisions

Example calls for the articles endpoint ::

(get)

  • Sample GET request written in Python with Requests.

  • Note: Presently, get requests only return a HTML response containing endpoint information.

  1. Declare the URL.

     >>> url ="http://scholarly.io/api/articles"
    
  2. Declare the mimetype and API version in the header.

     >>> headers = {"x-api-version": "alpha"}
    
  3. Post the request and capture the response.

     >>> response = requests.post(url, headers = headers)
    
  4. Successful posts should return a status code of 200 (success):

     >>> print response.status_code
     >>> 200
    
  5. Unsuccessful posts should return status code of 405 (user submission error):

     >>> print response.status_code
     >>> 405
    

(post)

  • Sample POST request written in Python with Requests.
  1. Declare the URL.

     >>> url = "http://scholarly.io/api/articles/"
    
  2. Declare the mimetype and API version in the header.

     >>> headers = {"Content-Type": "application/json", "x-api-version": "alpha"}
    
  3. Set the payload: Note: Scholarly only accepts a json consisting of a primary citation in Citation Style Language (CSL) format (OPTIONALLY) followed by a list of CSL format referenced citations and (OPTIONALLY) provenance information. The CSL schema can be found here: https://github.com/citation-style-language/schema/blob/master/csl-data.json

     >>> payload = {
     	"citation": { 
     		"id": "item1",
     		"title": "Some article about domokuns.",
     		"author": [
     			{"given": "tim",
     			"family": "tom" } 
     		],
     		"type": "book"
     	},
    
     	"references": [
     		{
     			"id": "item2",
     			"title": "Some older article about some domokuns.",
     			"author": [
     				{"given": "chevy",
     				"family": "chaser" } 
     			],
     			"type": "book"
     		},
     		{ 
     			"id": "item3",
     			"title": "Some article about some domokun lovers.",
     			"author": [
     				{"given": "kim",
     				"family": "possibly" } 
     			],
     			"type": "book",
     			"doi": "asdflkj209asdlkfj209sadfkj2"
     		},
     		{ 
     			"id": "item4",
     			"title": "Some article about some people who made their fortunes from selling domokuns.",
     			"author": [
     				{"given": "lyla",
     				"family": "lilly" },
     				{"given": "jimmy",
     				"family": "jaseper"} 
     			],
     			"type": "webpage",
     			"url": "http://www.pewpew.com/domokun_seller_gets_rich"
     		}
     	],
    
     	"metadata": {
     		"source": "some submitter",
     		"parse_style": "manual / parscite / scraping"
     	}	 
     }
    
  4. Post the request and capture the response.

     >>> response = requests.post(url, data=sample_payload, headers=headers)
    
  5. Successful posts should return a status code of 201 (successfully created):

     >>> print response.status_code
     >>> 201
    
  6. Unsuccessful posts should return status code of 405 (user submission error):

     >>> print response.status_code
     >>> 405
    

Example calls for the raw endpoint ::

(get)

  • In progress.

(post)

  • In progress.
Clone this wiki locally