libscipaper 1.0.x
User API

This API provides the external functionality required to use libscipaper in your application to get document metadata as well as full text.

The gist of the API to query a paper or multiple papers is:

  1. Edit scipaper.ini to provide your API keys and other information to libscipaper
    • provide your edited .ini file to libscipaper via the parameters to sci_paper_init()
  2. Create a DocumentMeta struct with document_meta_new()
    • fill any combination of fields you would like to search for like for instance .author = "Klemm" and .abstract = "String theory".
    • all filled fields will be AND'ed in your search
  3. Optionally, if you require that the results libscipaper returns must contain specific metadata fields you can also add a FillReqest and set the appropriate bits for the fields you require
    • This will cause libscipaper to not return with the result from first backend that manages to fill your search query, instead libscipaper will continue aggregating the results from all backends until all your requested fields are found or libscipaper runs out of backends.
  4. Query libscipaper for documents matching your DocumentMeta struct with sci_fill_meta() getting a RequestReturn struct in return
  5. Loop over the DocumentMeta structs in the RequestReturn and select some papers that interest you
  6. You can grab the full text of the papers in question by calling sci_get_document_text(), sci_get_document_pdf_data() or sci_save_pdf_to_file()
  7. You can save your results to disk via document_meta_save()

Usually the default behavior of scipaper returning the result from the first backend that matches your query is what you want, but if this is not what you want, you can specify a backend for libscipaper to use by setting the backendId variable in your DocumentMeta query struct to the id of a backend found with sci_get_all_backends() or sci_backend_get_id_by_name()

Full API documentation can be found here: User API

Example usage:


#include <stdio.h>
#include <stdbool.h>
#include <scipaper/scipaper.h>

#define MAX_RESULTS 200

int main(int argc, char** argv)
{
    bool ret = sci_paper_init(NULL, NULL, 0);
    if(!ret)
    {
            printf("Could not init libscipaper");
            return 1;
    }

    char doi[] = "10.1109/DSP-SPE.2011.5739265";
    DocumentMeta meta;
    meta.doi = doi;
    RequestReturn* filledMetas =  sci_fill_meta(&meta, NULL, MAX_RESULTS, 0);

    if(filledMetas)
    {
            printf("Found %i documents that match\n", filledMetas->count);
            printf("Found document with doi of: %s\n", doi);
            if(filledMetas->documents[0]->title)
                    printf("Title: %s\n", filledMetas->documents[0]->title);
            if(filledMetas->documents[0]->author)
                    printf("Author: %s\n", filledMetas->documents[0]->author);
            if(filledMetas->documents[0]->journal)
                    printf("Journal: %s\n", filledMetas->documents[0]->journal);

            bool saved = sci_save_document_to_pdf(filledMetas->documents[0], "out.pdf");
            if(saved)
                    printf("Was able to save pdf of document\n");
            else
                    printf("Was not able to save pdf of document\n");
    }
    else
    {
            printf("Unable to find document with doi of: %s\n", doi);
    }

    request_return_free(filledMetas);
    sci_paper_exit();
    return 0;
}