Skip to content

Instantly share code, notes, and snippets.

@chussenot
Created March 2, 2017 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chussenot/b77e243ea22b6e7140f810088c534632 to your computer and use it in GitHub Desktop.
Save chussenot/b77e243ea22b6e7140f810088c534632 to your computer and use it in GitHub Desktop.

Buffer API

API that delivers dnb JSON stream.

This API,

  • respect REST rules of use
  • is version controlled (not yet)
  • have coherent return HTTP codes (40x,50x,20x)
  • have fault handling
  • have response caching
  • is accessible from the 'URL (URL) by building URLs from the segments listed in this document.

REST

A RESTful concept, a resource path is a uniform resource identifier (URI) that identifies the network path to a given resource.

Version

The version of the developer-facing API interface. For example, vwt.com/buffer/v1.

HTTP status codes Overview

  • 200 OK - Everything worked as expected.
  • 204 OK - Everything worked as expected. (No message Body)
  • 400 Bad Request - Often missing a required parameter.
  • 401 Unauthorized - No valid API key provided.
  • 402 Request Failed - Parameters were valid but request failed.
  • 404 Not Found - The requested item doesn't exist.
  • 500, 502, 503, 504 Server errors - something went wrong on backend.

Caching

API Segments

Testing in preproduction

First your must declare your BUFFER url and your TOKEN

$ export BUFFER=https://l788b5qdxh.execute-api.eu-west-1.amazonaws.com/uat
$ export TOKEN=0DQpKCw5uHoWEqbbIu7B4r7FqTVpQE97R5K0vGBe

The with curl and jq for JSON formating you can test all the endpoints

To help you testing check for valid DUNS numbers here

GET /ping

Return pong

This route will return the lambda parameters only in dev ou ppd envs

$ curl -H 'Cache-Control: no-cache' -v $BUFFER/ping | jq

POST /executives

Return a DUNS profile with executives informations

Body Parameters:

  • duns (Integer) (required) : DUNS number
$ curl -H 'Cache-Control: no-cache' -v -H "x-api-key: 0DQpKCw5uHoWEqbbIu7B4r7FqTVpQE97R5K0vGBe" -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"duns":788138980}' $BUFFER/executives

POST /profile

Return a DUNS profile

Body Parameters:

  • duns (Integer) (required) : DUNS number
$ curl -H 'Cache-Control: no-cache' -v -H "x-api-key: $TOKEN" -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"duns":788138980}' $BUFFER/profile

POST /match

Search matches for your given parameters

Body Parameters:

  • duns (Integer) (optional) : DUNS number

All parameters can be found here https://docs.dnb.com/direct/plus/en-US/match/latest/index#FeatureRequest

$ curl -H 'Cache-Control: no-cache' -v -H "x-api-key: $TOKEN" -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"duns":788138980}' $BUFFER/match

$ curl -H 'Cache-Control: no-cache' -v -H "x-api-key: $TOKEN" -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{
  "name": "D2SI",
  "countryISOAlpha2Code": "FR"
}' $BUFFER/match

$ curl -H 'Cache-Control: no-cache' -v -H "x-api-key: $TOKEN" -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{
  "name": "AMR Corporation",
  "StreetAddressLine1": "4333 Amon Carter Blvd.",
  "addressRegion": "TX",
  "postalCode": 76155,
  "countryISOAlpha2Code": "US"
}' $BUFFER/match
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment