Skip to end of metadata
Go to start of metadata

GET: Retrieve an Individual Item Document


You can easily retrieve all of the information on an item in JSON, XML, or ATOM format using REST Services with a tool such as the RESTClient plugin for Firefox (https://addons.mozilla.org/en-US/firefox/addon/restclient/) or in Groovy using a library like HTTPBuilder (http://groovy.codehaus.org/modules/http-builder/) or using the URL and JSON objects that Groovy provides.

Get requests are simple, you just send a get request to the specific URL of the item you are requesting. Eg. http://www.sciencebase.gov/catalog/item/<itemId> where itemId is the SB2 item ID of the requested item. (example: if the itemId is 4f4e4b24e4b07f02db6aea14 the URL is:  https://www.sciencebase.gov/catalog/item/4f4e4b24e4b07f02db6aea14 )

GET: an individual item (JSON)

To get an item's SB JSON you need to add the format argument in the URL and set it equal to json. Following on the example above, if you want the SB JSON of the item with itemId equal to 4f4e4b24e4b07f02db6aea14 the URL will be: https://www.sciencebase.gov/catalog/item/4f4e4b24e4b07f02db6aea14?format=json

GET: an individual item (JSONP)

To get an item's SB JSON in JSONP format (JSON wrapped in a javascript function http://en.wikipedia.org/wiki/JSONP) you again need to add the format argument in the URL, but this time set it equal to jsonp. (example with itemId equal to 4f4e4b24e4b07f02db6aea14, the URL will be: https://www.sciencebase.gov/catalog/item/4f4e4b24e4b07f02db6aea14?format=jsonp). By default the returned function is called getSBJSON. If you want to use a different function name you need to add the jsonp or callback argument in the url. For example, if I want to set the function name equal to parseResponse you first need the format=jsonp argument and then you also need a jsonp=parseResponse argument. If the itemId is 4f4e4b24e4b07f02db6aea14 the URL will be: https://www.sciencebase.gov/catalog/item/4f4e4b24e4b07f02db6aea14?format=jsonp&jsonp=parseResponse

GET specific fields of an item

You can also limit the number of fields returned from a GET on an item by adding the query to the URL like this: "?fields=title,subtitle,body". This is just like specifying the fields you want returned on a search, see Creating Queries for ScienceBase - Old 3/10/14.

Default Fields

identifiers,title,subTitle,alternateTitles,summary,body,purpose,rights,provenance,materialRequestInstructions,hasChildren,parentId,contacts,webLinks,browseCategories,browseTypes,systemTypes,tags,dates,spatial,extents,facets,files,distributionLinks,previewImage,locked

Other Fields

relationships,usgscitation


Example Output

For more information on the returned fields see ScienceBase Item Core Model.

Response (as formatted JSON)

{
    "link": {
        "rel": "self",
        "url": "http://www.sciencebase.gov/catalog/item/1234567890abcdef12345667"
    },
    "id": "4ee16534e4b0f37470fe4a1c",
    "oldId": 1810147,
    "oldUuid": "5d2e9bf2-0326-4eff-8eaf-529cdd0e3889",
    "identifiers": [
        {
            "type": "repo",
            "scheme": "sciencebase",
            "key": "ebadf3b6-5074-48e3-beb8-4653ac4bb799"
        }
    ],
    title: "Sample Item Title",
    subTitle: "The subtitle",
    summary: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam eu nibh ante, eget interdum lectus. Curabitur ac malesuada urna.",
    "body": "the abstract of the item",
    "purpose": "the purpose if one has been recorded",
    "rights": "the rights if recorded",
    "provenance": "the provenance if recorded",
    "materialRequestInstructions": "how to request the material - mostly relevant to Physical Collections/Items",
    "tableOfContents": "",
    "edition": "",
    "alternateTitles": ["My Alternate Title", "My Alternate Title #2"],
    "narratives": [],
    "hasChildren": false,
    "parentId": "4ee13c63e4b0f37470f229a0",
    "contacts": [
        {
            type: "Author",
            name: "John Doe",
            oldPartyId: null,
            highlighted: false
        }
    ],
    webLinks: [
        {
            href: "https://my.usgs.gov/repo/file/download/communities/WaterSMART/Draft/AIR_020107.shp",
            rel: "alternate",
            title: "Download",
            hidden: false
        },
        {
            href: "https://my.usgs.gov/repo/node/browse/communities/WaterSMART/Draft/AIR_020107.shp",
            rel: "via",
            title: "ScienceBase Repository",
            hidden: false
        },
        {
            href: "https://my.usgs.gov/repo/mapping/ows/communities/WaterSMART/Draft/AIR_020107.shp",
            rel: "http://www.sciencebase.gov/vocab/linkRelations/serviceCapabilitiesUrl",
            title: "OGC Service Capabilities URL",
            hidden: true
        },
        {
            href: "https://my.usgs.gov/repo/mapping/ows/communities/WaterSMART/Draft/AIR_020107.shp",
            rel: "http://www.sciencebase.gov/vocab/linkRelations/serviceMapUrl",
            title: "OGC Service Map URL",
            hidden: true
        },
        {
            href: "https://my.usgs.gov/repo/mapping/ows/communities/WaterSMART/Draft/AIR_020107.shp",
            rel: "http://www.sciencebase.gov/vocab/linkRelations/serviceFeatureInfoUrl",
            title: "OGC Service Feature Info URL",
            hidden: true
        }
    ],
    tags: [
        {
            type: "ItemType",
            scheme: "http://www.sciencebase.gov/vocab/category/item/types",
            term: "Online Data",
            categoryId: "4ee13c53e4b0f37470f2278c"
        },
        {
            type: "ItemType",
            scheme: "http://www.sciencebase.gov/vocab/category/item/types/Online%20Data",
            term: "Uploaded Shapefile",
            categoryId: "4ee13c55e4b0f37470f227c9"
        }
    ],
    spatial: {
        representationalPoint: [
            1.98616682419483,
            47.1881842414308
        ],
        representationalPointIsDerived: true
    },
    facets: [
        {
            className: "gov.sciencebase.catalog.item.facet.ShapefileFacet",
            name: "AIR_020107",
            geometryType: "MultiPolygon",
            nativeCrs: "EPSG:5070",
            files: [
                {
                    name: "AIR_020107.dbf",
                    contentType: "application/octet-stream",
                    pathOnDisk: "70/7a/e9/707ae9a005d4e5a9385ca1b0f1bad90771fc075e"
                },
                {
                    name: "AIR_020107.shp",
                    contentType: "x-gis/x-shapefile",
                    pathOnDisk: "f8/4e/60/f84e601c960bda8a0189c191287ccddeb4d0c802"
                },
                {
                    name: "AIR_020107.shp.xml",
                    contentType: "application/xml",
                    pathOnDisk: "0a/dd/8f/0add8f52460e93c3f8832790c7ae539106d890f7"
                },
                {
                    name: "AIR_020107.prj",
                    contentType: "text/plain",
                    contentEncoding: "ISO-8859-1",
                    pathOnDisk: "3a/69/7d/3a697d45203a6aded491207f3c9ab3317d440fdb"
                },
                {
                    name: "AIR_020107.sbn",
                    contentType: "x-gis/x-shapefile",
                    pathOnDisk: "75/a7/f0/75a7f0c105c0add90c1ba11a2dc613e6a626d5ce"
                },
                {
                    name: "AIR_020107.shx",
                    contentType: "x-gis/x-shapefile",
                    pathOnDisk: "b4/53/81/b45381fdf20fd8eeff7f2e0671da52c8ba69261c"
                },
                {
                    name: "AIR_020107.sbx",
                    contentType: "x-gis/x-shapefile",
                    pathOnDisk: "5a/31/a3/5a31a38dcb68058ee74e4601c19d5e58bd88c363"
                }
            ]
        }
    ],
    files: [
        {
            name: "AIR_020107.dbf",
            contentType: "application/octet-stream",
            pathOnDisk: "70/7a/e9/707ae9a005d4e5a9385ca1b0f1bad90771fc075e"
        },
        {
            name: "AIR_020107.shp",
            contentType: "x-gis/x-shapefile",
            pathOnDisk: "f8/4e/60/f84e601c960bda8a0189c191287ccddeb4d0c802"
        },
        {
            name: "AIR_020107.shp.xml",
            contentType: "application/xml",
            pathOnDisk: "0a/dd/8f/0add8f52460e93c3f8832790c7ae539106d890f7"
        },
        {
            name: "AIR_020107.prj",
            contentType: "text/plain",
            contentEncoding: "ISO-8859-1",
            pathOnDisk: "3a/69/7d/3a697d45203a6aded491207f3c9ab3317d440fdb"
        },
        {
            name: "AIR_020107.sbn",
            contentType: "x-gis/x-shapefile",
            pathOnDisk: "75/a7/f0/75a7f0c105c0add90c1ba11a2dc613e6a626d5ce"
        },
        {
            name: "AIR_020107.shx",
            contentType: "x-gis/x-shapefile",
            pathOnDisk: "b4/53/81/b45381fdf20fd8eeff7f2e0671da52c8ba69261c"
        },
        {
            name: "AIR_020107.sbx",
            contentType: "x-gis/x-shapefile",
            pathOnDisk: "5a/31/a3/5a31a38dcb68058ee74e4601c19d5e58bd88c363"
        }
    ],

    dates: [type:"Publication Date", dateString:"2007"],

}

Notes About GET and the Item collection

  • 404 is returned when no matching records found for ID
  • No labels