Consumer Health

 

Browse our guides and interact with our API reference for more information about MEDSAPI NAH Reference Center. Try the API and learn about core concepts.

 

 

 

 

Get Articles by ID Code Samples

Use the code samples below as examples to create an application in your desired language.  The following code samples use the /v1/content/articles/{id} endpoint to get an article.  Get started and begin to understand the endpoint by following the examples below in the language of your choice. Substitute a valid token for the placeholder below to run the examples.

 

Code Samples

cURL
# Get an NAH Reference Center article

curl -X GET "https://apis.ebsco.com/medsapi-ref-ctr/v1/content/articles/{id}?secure=true&imageSize=large&posterSize=small&mediaLinksFormat=server"
    -H "authorization: Bearer TOKEN"
    -H "Content-Type: application/json"
    -H "Accept: application/json"


Java
// Get an NAH Reference Center article

// Construct the client
OkHttpClient client = new OkHttpClient();

// Create the URL
HttpUrl url = new HttpUrl.Builder()
    .scheme("https")
    .host("apis.ebsco.com")
    .addPathSegment("medsapi-ref-ctr")
    .addPathSegment("v1")
    .addPathSegment("content")
    .addPathSegment("articles")
    .addPathSegment("{id}")
    .addQueryParameter("secure", "true")
    .addQueryParameter("imageSize", "large")
    .addQueryParameter("posterSize", "small")
    .addQueryParameter("mediaLinksFormat", "server")
    .build();


// Build the request
Request request = new Request.Builder()
    .url(url)
    .get()
    .addHeader("authorization, "Bearer TOKEN")
    .addHeader("Content-Type, "application/json")
    .addHeader("Accept, "application/json")
    .build();

// Send the request
Response response = client.newCall(request).execute();

JavaScript
// Get an NAH Reference Cebter article

const host = "https://apis.ebsco.com";
const path = "/medsapi-ref-ctr/v1/content/articles/{id}";

// Create the Request
const url = host + path;
const queryParams = {"secure": true, "imageSize": large, "posterSize": small, "mediaLinksFormat": server}

const settings = {
    "async": true,
    "crossDomain": true,
    "url": url,
    "method": "GET",
    "headers": {
        "authorization": "Bearer TOKEN",
        "Content-Type": "application/json",
        "Accept": "application/json"
    },
    "data": queryParams
};

// Send the Request
$.ajax(settings).done(function (response) {
    console.log(response);
});

Ruby

# Get an NAH Reference Center article

# Form the URL
urlstr = File.join("https://", "apis.ebsco.com", "/medsapi-ref-ctr/v1/content/articles/{id}")
url = URI.parse(urlstr)
params = { :secure => true,:imageSize => large,:posterSize => small,:mediaLinksFormat => server }

# Add params to URI
uri.query = URI.encode_www_form( params )

# Create the HTTP object
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

# Create the request
request = Net::HTTP::Get.new(url)
request["authorization"] = "Bearer TOKEN"
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"


# Send the request
response = http.request(request)

Python
# Get an NAH Reference Center article

# Form the URL
url = "/medsapi-ref-ctr/v1/content/articles/{id}"

queryParams = {
    "secure": true
    "imageSize": large
    "posterSize": small
    "mediaLinksFormat": server}

# Create Connection Instance
conn = http.client.HTTPSConnection("apis.ebsco.com")

# Create the Request Headers
headers = {
        "authorization": "Bearer TOKEN",
        "Content-Type": "application/json",
        "Accept": "application/json"
}

# Send Request
conn.request("GET", url, queryParams, headers)