Consumer Health

 

Browse our guides and interact with our API reference for more information about MEDSAPI Consumer Health. Try MEDSAPI Consumer Health and learn about core concepts.

 

 

 

 

Search 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/search endpoint to search articles.  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
# Search Consumer Health:

curl -X POST "https://apis.ebsco.com/medsapi-consumer-health/v1/content/search" -H "accept: application/json" 
-H "Authorization: Bearer TOKEN" -H "Content-Type: application/json" -d "{ \"query\": \"chromosomal abnormalities\", \"pageSize\": 10, 
\"fields\": [ \"title\" ]}"
Java
// Search Consumer Health:

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

// Create the URL
HttpUrl url = new HttpUrl.Builder()
    .scheme("https")
    .host("apis.ebsco.com")
    .addPathSegment("medsapi-consumer-health")
    .addPathSegment("v1")
    .addPathSegment("content")
    .addPathSegment("search")
    .build();

// Build the body   
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{ \"query\": \"chromosomal abnormalities\", \"pageSize\": \"10\", \"fields\": [ \"title\" ]}");  

// Build the request
Request request = new Request.Builder()
    .url(url)
    .post(body)
    .addHeader("Accept", "application/json")
    .addHeader("Authorization", "Bearer TOKEN")
    .addHeader("Content-Type", "application/json")
    .build();
JavaScript
// Search Consumer Health: 

const host = "https://apis.ebsco.com";
const  path = "/medsapi-consumer-health/v1/content/search";

// Create the Request
const url = host + path;
const requestBody = {
  "query": "chromosomal abnormalities",
  "pageSize": 10,
  "fields": [
    "title"
  ]
};
const settings = {
  "async": true,
  "crossDomain": true,
  "url": url,
  "method": "POST",
  "processData": false,
  "data": JSON.stringify(requestBody),
  "headers": {
        Accept: "application/json",
        Authorization: "Bearer TOKEN",
        "Content-Type": "application/json"
  }  
}

// Send the Request
$.ajax(settings).done(function (response) {
  console.log(response);
});
Ruby
# Search Consumer Health

# Form the URL 
urlstr = File.join('https://', 'apis.ebsco.com', '/medsapi-consumer-health', '/v1/content/search')
url = URI(urlstr)

# 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::Post.new(url)
request["Accept"] = "application/json"
request["Authorization"] = "Bearer TOKEN"
request["Content-Type"] = "application/json"
request.body = { query: 'chromosomal abnormalities', pageSize: '10', fields: [ 'title' ]}.to_json

# Send the request
response = http.request(request)
Python
# Search Consumer Health

# Form the URL
url = ''.join(['/medsapi-consumer-health','/v1', '/content/search'])

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

# Payload
payload = '{"query":"chromosomal abnormalities","pageSize":10,"fields":["title"]}'

# Create the Request Headers
headers = {
    "Authorization": "Bearer TOKEN",
    "Accept": "application/json",
    "Cache-Control": "no-cache",
    }

# Send Request  
conn.request("POST", url, payload, headers)