Retrieve data from third-party API using Basic Authentication, display as feature layer?

559
3
Jump to solution
01-23-2020 06:11 PM
JackSilburn
New Contributor III

Hi


I am curious to know if it is possible to do the following:

  • create an ArcGIS Online item/feature/application which calls a non-ArcGIS API endpoint,
  • the API returns a JSON response when queried,
  • the API also requires Basic Authentication.

The data is interpreted as an ArcGIS Online 'friendly' format (e.g. feature layer? Table?), which can then be added to Web Maps, Applications, Ops Dashboard etc.

Thanks

0 Kudos
1 Solution

Accepted Solutions
JackSilburn
New Contributor III

Hi Peter

I ended up following a fairly convoluted (and bespoke) process:

  1. I am using a linux server to run a python program on an automated schedule
  2. The program handles the API requests, using the Python Requests module, to return JSON data
  3. The program then queries the AGOL API, returning a list of GIS features and associated primary keys
  4. The program joins the two datasets from steps 2 & 3, and POSTs the completed table back to AGOL, via the UpdateFeatures API method.

I now have a feature layer which is updated automatically with 'live' data, which I can use in Web Maps and so forth.

I believe I tried something following your first link, but for whatever reason it wasn't working out.

Thanks

View solution in original post

0 Kudos
3 Replies
Peter_Klingman
Esri Regular Contributor

Hi Jack Silburn‌,

Thanks for the post. Were you able to get this to work?

I think this question ultimately depends on the JSON response when queried. From this doc, if the response is valid GeoJSON then you would be able to add it to a web map and create a hosted feature layer: What can you add to ArcGIS Online?—ArcGIS Online Help | DocumentationImport data | ArcGIS for Developers 

Developer Communities‌ would maybe have more to add on the authentication component. 

Hope this helps,

-Peter 

0 Kudos
JackSilburn
New Contributor III

Hi Peter

I ended up following a fairly convoluted (and bespoke) process:

  1. I am using a linux server to run a python program on an automated schedule
  2. The program handles the API requests, using the Python Requests module, to return JSON data
  3. The program then queries the AGOL API, returning a list of GIS features and associated primary keys
  4. The program joins the two datasets from steps 2 & 3, and POSTs the completed table back to AGOL, via the UpdateFeatures API method.

I now have a feature layer which is updated automatically with 'live' data, which I can use in Web Maps and so forth.

I believe I tried something following your first link, but for whatever reason it wasn't working out.

Thanks

0 Kudos
Peter_Klingman
Esri Regular Contributor

Hi Jack,

Thanks for following up on this - I'll go ahead and mark your answer as correct to help anyone else that comes across the thread; as you mention it is customized for your scenario but I suspect other folks have similar end goals. 

If you haven't yet I would recommend checking out Notebooks beta and trying it our for some of your workflows - it provides access to the ArcGIS API for Python and general Python functions in the cloud. 

Cheers,

-Peter

0 Kudos