Open Science Framework

Science

Accessing Public API Docs on OSF

As a developer seeking to build integrations with OSF, the Open Science Framework, the first point of contact is the developer portal located at developer.osf.io. At this repository, you can build tailored integrations that aid your research processes and connect these integrations to OSF APIs directly.

To explore the wealth of OSF public APIs available to developers, visit the Public API Documentation page. Here, you can find APIs for every aspect of the OSF research workflow, from creating and viewing projects, files, and folders to collaborating with colleagues on research outcomes.

To illustrate how readily these APIs can be integrated with your code, let us take an example using JavaScript.

The code below demonstrates how to retrieve a list of nodes from an OSF project using the nodes API:

    // Import axios, a powerful AJAX library
    const axios = require('axios');

    // Define the URL to the nodes API endpoint
    const nodesUrl = 'https://api.osf.io/v2/nodes/';

    // Define a function to get nodes
    const getNodes = () => {

        // Create a request to the nodes API endpoint
        return axios

            .get(nodesUrl)

            // Process the response data
            .then(response => {
                const nodes = response.data.data;
                return nodes;
            })

            // Handle errors
            .catch(error => {
                console.log('Error:', error);
            });
    }

    // Call the getNodes function
    getNodes();

In this example, we start by importing the axios AJAX library. We then define the URL of the nodes endpoint and create a getNodes function that makes a request to the endpoint and processes the response data.

Calling the getNodes function will then return a list of nodes from the specified OSF project.

In conclusion, the OSF public API documentation provides developers with access to numerous powerful APIs that can enhance their research workflows. The example above demonstrates how easily these APIs can be integrated with JavaScript, opening up endless possibilities for creating personalized research tools.

Related APIs in Science