Extracting metadata from an article/submission - OJS 3.4.0-4

I am exploring options to extract metadata from an article/submission hosted on OJS using REST API. I have written a script in PHP and it could not extract the metadata (see the script below). I was wondering if anyone has developed or come across a script specifically designed for this purpose? Specifically, I’m interested in obtaining metadata fields such as title, authors, abstract, keywords, publication date, etc.

Any guidance, scripts (PHP/Python), or recommendations would be highly appreciated.

Thank you for your assistance!


// OJS base URL and API endpoint
$baseUrl = ‘https://james.uit.no/ojs3404’; // Replace with your OJS base URL
$apiEndpoint = ‘/index.php/testA/api/v1/submissions/6545/publications’; // Replace {joural_id} and {article’s submission_id} with the actual journal ID and Sumbission ID respectively
// API authentication headers
$headers = [
‘Authorization: eyJ0eXAixxxxxxxxx’, // Replace with your API key if required
‘Content-Type: application/json’

// Initialize cURL session
$ch = curl_init();

// Set cURL options
curl_setopt($ch, CURLOPT_URL, $baseUrl . $apiEndpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

// Execute cURL session and fetch response
$response = curl_exec($ch);

// Check if cURL request was successful
if (curl_errno($ch)) {
echo 'Error occurred: ’ . curl_error($ch);
} else {

$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo “$httpCode. \n”;
// Decode JSON response
$articleMetadata = json_decode($response, true);

// Extract relevant metadata (adjust based on your requirements)
$title = $articleMetadata['title'] ?? 'N/A';
$authors = array_column($articleMetadata['authors'] ?? [], 'name');
$abstract = $articleMetadata['abstract'] ?? 'N/A';

// Output extracted metadata
echo "Title: {$title}\n";
echo "Authors: " . implode(', ', $authors) . "\n";
echo "Abstract: {$abstract}\n";


// Close cURL session


Hi @obi,

If you’re having trouble using an API key, the most common cause is that the api_key_secret is not configured in config.inc.php. If it isn’t, add some data there, then re-generate the API key and try again.

(You’ve probably already considered this, but have a look also at the OAI-PMH interface. This has a few formats built in, but can be extended to export metadata via JATS by installing both the JATSTemplate and OAI JATS plugins; both are in the Plugin Gallery.)

Alec Smecher
Public Knowledge Project Team

Thanks for your quick reply.
api_key_secret is configured in config.inc.php. When I put the query on a browser, it generates json format but has no information about abstract, authors, etc other dublincore medatadata as explained here: https://docs.pkp.sfu.ca/dev/api/ojs/3.4#tag/Submissions-Publications

my example: https://james.ub.uit.no/ojs3404/index.php/1700/api/v1/submissions/6545/publications?apiToken=eyJ0eXXX

I have tried OAI-PMH interface and no good result. My example as follows:


// OAI-PMH base URL
$oaiBaseUrl = ‘https://james.ub.uit.no/ojs3404/index.php/index/oai’;

// Article identifier (replace with the actual identifier of the article)
$articleIdentifier = ‘oai:james.ub.uit.no:article/828’; // Format may vary based on your OJS configuration


// Set parameters for GetRecord request
$params = [
‘verb’ => ‘GetRecord’, // OAI verb to fetch a specific record
‘identifier’ => $articleIdentifier, // Unique identifier of the article
‘metadataPrefix’ => ‘oai_dc’, // Dublin Core metadata format

// Construct the OAI-PMH request URL
$requestUrl = $oaiBaseUrl . ‘?’ . http_build_query($params);

// Initialize cURL session
$ch = curl_init();

// Set cURL options
curl_setopt($ch, CURLOPT_URL, $requestUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the response as a string
curl_setopt($ch, CURLOPT_HEADER, false); // Exclude the header from the output
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); // Timeout in seconds

// Execute cURL session and get the response
$response = curl_exec($ch);

// Check for cURL errors
if (curl_errno($ch)) {
echo 'Error fetching OAI request: ’ . curl_error($ch);
// Handle the error appropriately
} else {
// Process the OAI-PMH XML response
$xml = simplexml_load_string($response);

// Check for OAI errors
if (isset($xml->error)) {
    echo 'OAI Error: ' . $xml->error->attributes()['code'] . ' - ' . $xml->error;
    // Handle the OAI error appropriately
} else {
    // Extract and process the metadata of the article
    $title = (string) $xml->GetRecord->record->metadata->children('oai_dc', true)->title;
    $keywords = $xml->GetRecord->record->metadata->children('oai_dc', true)->subject;
    $authors = $xml->GetRecord->record->metadata->children('oai_dc', true)->creator;
    $abstract = (string) $xml->GetRecord->record->metadata->children('oai_dc', true)->description;

    // Display or process the extracted metadata
    echo "Title: $title\n";
    //echo "Keywords: " . implode(', ', $keywords) . "\n";
    //echo "Authors: " . implode(', ', $authors) . "\n";
    echo "Abstract: $abstract\n";


// Close cURL session



This topic was automatically closed after 10 days. New replies are no longer allowed.