IDigBio API v1 Examples: Difference between revisions

add note about json.tool and json_pp
(add Elasticsearch section)
(add note about json.tool and json_pp)
Line 1: Line 1:
[[Category:CYWG]]
See [[IDigBio API]] for full documentation on the API including all of the available endpoints.
[[Category:API]]
 
[[Category:Documentation]]
For best sampling of JSON results in a browser, you may wish to use the JSONView Extension for Chrome and Firefox.
 
In most cases for these examples we format the output of the JSON document using a "pretty printing" feature of some kind in order to make this document more readable by humans.
 
For example, this is the raw JSON returned by the base URL of the api:
 
<pre>
$ curl -s http://api.idigbio.org/
{"v1":"http://api.idigbio.org/v1/","v0":"http://api.idigbio.org/v0/","check":"http://api.idigbio.org/check"}
</pre>
 
We make this easier to read by a human if we pipe the output through a formatter such as python's json.tool or the json_pp command-line Perl script (JSON::PP).


See [[IDigBio API]] for documentation on the APIs beyond what is provided here.
==== json.tool Example ====
<pre>
$ curl -s http://api.idigbio.org/ | python -m json.tool
{
    "check": "http://api.idigbio.org/check",
    "v0": "http://api.idigbio.org/v0/",
    "v1": "http://api.idigbio.org/v1/"
}
</pre>


==== json_pp Example ====
<pre>
$ curl -s http://api.idigbio.org/ | json_pp
{
  "v1" : "http://api.idigbio.org/v1/",
  "check" : "http://api.idigbio.org/check",
  "v0" : "http://api.idigbio.org/v0/"
}
</pre>


For best sampling of JSON results in a browser, you may wish to use the JSONView Extension for Chrome and Firefox.
==== JSONView Browser Extension Example ====


Most of our examples here will look at a text-based version of the data.
Here goes a screenshot.


=== Fetch A Single Record from the API ===
=== Fetch A Single Record from the API ===
Line 156: Line 184:


See also [[iDigBio API Performance]].
See also [[iDigBio API Performance]].
[[Category:CYWG]]
[[Category:API]]
[[Category:Documentation]]
1,554

edits