Expand my Community achievements bar.

Reactor API Fetch all production libraries

Avatar

Level 2

Hello,

I am using Adobe data collection Reactor API, and want to know if following is possible, and if yes, how:

Can I extract all the libraries published in 2023 from my adobe launch property?

I am using following code, but it just extracts current libraries:

https://reactor.adobe.io/properties/{PROPERTY_ID}/libraries

1 Reply

Avatar

Level 2

Hey @SaurabhCh ,

 

Collection Reactor API, you need to modify your API request to filter the libraries based on their publishing dates. The basic API endpoint you're using (https://reactor.adobe.io/properties/{PROPERTY_ID}/libraries) fetches the libraries associated with a specific property, but without additional filtering, it returns the current set of libraries.

Steps to Extract Libraries Published in 2023:

  1. API Documentation:

    • First, review the Adobe Data Collection (Reactor API) documentation to understand the available query parameters and how to filter the results by date.
  2. Filtering by Date:

    • The API might offer a way to filter libraries based on their 'published' date. This could involve adding query parameters to your API call.
  3. Pagination Handling:

    • If there are many libraries, the API might paginate the results. Ensure that your code can handle pagination to retrieve all relevant libraries.
  4. API Request Example:

  5. Scripting the Extraction:

    • Use a scripting language like Python or JavaScript to make the API call and handle the JSON response.
    • Loop through the paginated results (if applicable) and filter the libraries based on the publishing date.
  6. Error Handling and Validation:

    • Include error handling in your script to manage any API request failures.
    • Validate the results to ensure that the data is accurate and complete.

Sample Code Snippet:

Here's a basic JavaScript example using fetch to illustrate how you might structure the request. Note that this is a generic template:

 

 

 

const PROPERTY_ID = 'your-property-id'; // Replace with your Property ID
const url = `https://reactor.adobe.io/properties/${PROPERTY_ID}/libraries?published_after=2023-01-01&published_before=2024-01-01`;

fetch(url, {
  headers: {
    'Authorization': 'Bearer your-access-token', // Replace with your access token
    'Content-Type': 'application/vnd.api+json'
  }
})
.then(response => response.json())
.then(data => {
  console.log('Libraries Published in 2023:', data);
})
.catch(error => {
  console.error('Error fetching libraries:', error);
});

 

Note:

  • Authentication: Ensure that your API call includes proper authentication (usually a Bearer token).
  • API Version: Check for the latest version of the API and any recent changes that might affect how the API call is structured.

Finally, if you're unable to find the required filtering capability in the existing API, consider retrieving all libraries and then filtering them based on the publishing date within your script. This approach, however, might be less efficient, especially if there are a large number of libraries.

 

Regards,

Eugene