If I understand your question right, you have a data from an external API and want to write the data to Azure Cosmos DB? You can use SDK/Drivers to connect to the Cosmos DB account depending on the API type and use the language of your choice to write code that fetches data from the external API. After fetching data from the external API, parse and transform it as needed to match the data model you've defined in your Cosmos DB collection. Rest of the logic remains the same as how you would write/insert data to Cosmos DB.
How do i get data from external API into cosmos db?
NickKhoo-7526
31
Reputation points
Hi,
I am exploring cosmos db as a data to store data that will be collected from public APIs from the internet. I am new to this technology. How do I get those data into cosmos db?
Appreciate it if anyone can provide some guidance.
Thanks
Nk
2 answers
Sort by: Most helpful
-
Sajeetharan 2,261 Reputation points Microsoft Employee
2023-10-31T13:25:59.1666667+00:00 -
Rumen Krastev 0 Reputation points Microsoft Employee
2023-11-09T17:07:00.8733333+00:00 Concretely, to add what Sajeetharan says, you're going to need a trigger (could be scheduled too), which upon event/time get the data from public API and save it to Cosmos. Here're some helpers:
- https://learn.microsoft.com/en-us/azure/logic-apps/tutorial-build-schedule-recurring-logic-app-workflow
- https://learn.microsoft.com/en-us/azure/connectors/connectors-native-http
- https://learn.microsoft.com/en-us/azure/connectors/connectors-create-api-cosmos-db?tabs=consumption#add-azure-cosmos-db-action
If you prefer videos, here's one: https://www.youtube.com/watch?v=oIwDgJPmVCg