Fetching Pull Requests Data from Github

It is very plausible that you may want get some extra data in your APIs that may not be actually stored in your database, but somewhere in another service you might be using. To give you can example, you want to show an overview of all the pull requests your team has made for an internal dashboard. You'd need to get that data from an external source, which in this case would be Github.

Canonic allows you to define a new Integration type of FieldSets that fetches data into these fieldSets from an external API. Let's see how we can get external data from the GitHub APIs:

  1. Create a new FieldSet, select the type as Integration and give it a name.

graph

  1. Select Github from the API Integrations Dropdown. You'll automatically see all the APIs that Github provides listed under it. For our example, let's select the "List pull requests" API.

    service

    integration

  2. Go to the API Configuration Tab. You'll see 3 settings there:

    • Authentication Add all the details required to authenticate the access to the Integration. In our case we'll be fetching the Pull Requests for a public repository, so we can leave it empty.

    πŸ’‘ Note: Way of authentication can be different for different integrations

    • Required Fields Fields that are necessary to make the API work as expected will be listed down here. In our case, we need to add the details of the repository we need to fetch details for. We used canonic's open source samples repos credentials for this example.

required_fields

  • Optional Fields If lists down all the different optional parameters that the API Supports:

optional_fields

You just created a custom data-source to your project πŸ™Œ Just hit deploy and head to the playground to see the magic. If you try querying your table for information, the pullRequests fieldSet will populate the response from Github API.

playground

Did you find what you were looking for?
πŸ‘
πŸ‘Ž
What went wrong?
Need more help?We have a thriving Discordcommunity that can help you with all things Canonic. β†’