Browse our guides and interact with our API reference for more information about MEDSAPI DynaMed/DynaMedex. Try MEDSAPI DynaMed/DynaMedex and learn about core concepts.

 

 

 

 

Dyna Search Code Samples

Use the code samples below as examples to create an application in your desired language.  The following code samples use the POST /v1/content/search/rag endpoint which allows you to execute a retrieval-augmented generation search against either DynaMedex content.  Get started and begin to understand the endpoint by following the examples below in the language of your choice. 

 

Code Samples

cURL
# Dyna Search content

curl -X POST "https://apis.ebsco.com/medsapi-dynamedex/v1/content/search/rag"
    -H "Content-Type: application/json"
    -H "Accept: application/json"
    -H "Authorization: Bearer TOKEN"
    -H "x-eis-id-token: ID token"
    -H "Connection: keep-alive"
    -H "Cache-Control: no-cache"
    -H "X-AccelBuffering: no"
    -d '{"criteria": "query","How do I evaluate an Infant for Congenital Heart Disease?"}'


 

Java
// Dyna Search content

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

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

// Build the body
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"criteria\": { \"query\": \"How do I evaluate an Infant for Congenital Heart Disease?\"}")

// Build the request
Request request = new Request.Builder()
    .url(url)
    .post(body)
    .addHeader("Content-Type", "application/json")
    .addHeader("Accept", "application/json")
    .addHeader("Authorization", "Bearer TOKEN")
    .addHeader("x-eis-id-token", "ID token")
    .addHeader("Connection", "keep-alive")
    .addHeader("Cache-Control", "no-cache")
    .addHeader("X-AccelBuffering", "no")
    .build();

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

JavaScript
// Dyna Search content

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

// Create the Request
const url = host + path;
const requestBody = {
  "criteria": {
    "query": "How do I evaluate an Infant for Congenital Heart Disease?"
  }
};

const settings = {
    "async": true,
    "crossDomain": true,
    "url": url,
    "method": "POST",
    "headers": {
        "Content-Type": "application/json",
        "Accept": "application/json",
        "Authorization": "Bearer TOKEN"
        "x-eis-id-token: ID token"
        "Connection: keep-alive"
        "Cache-Control: no-cache"
        "X-AccelBuffering: no"
    },
    "processData": false,
    "data": JSON.stringify(requestBody)
};

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

Ruby
# Dyna Search content

# Form the URL
urlstr = File.join("https://", "apis.ebsco.com", "/medsapi-dynamedex/v1/content/search/rag")
url = URI.parse(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["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request["Authorization"] = "Bearer TOKEN"
request["x-eis-id-token] = "ID token"
request["Connection] = "keep-alive"
request["Cache-Control] = "no-cache"
request["X-AccelBuffering] = "no"
request.body = {
  "criteria": {
    "question": "How do I evaluate an Infant for Congenital Heart Disease?"
  }
}

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

Python
# Dyna Search content

# Form the URL
url = "/medsapi-dynamedex/v1/content/search/rag"

# Payload
payload = {
  "criteria": {
    "query": "How do I evaluate an Infant for Congenital Heart Disease?"
  }
};

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

# Create the Request Headers
headers = {
        "Content-Type": "application/json",
        "Accept": "application/json",
        "Authorization": "Bearer TOKEN",
        "x-eis-id-token: ID token",
        "Connection: keep-alive",
        "Cache-Control: no-cache",
        "X-AccelBuffering: no"
}

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