Question: Is there a way to use Wolfram Cloud to create a web API function that, when pinged, does the following:

  1. Gets the geographical location of the user (as an Wolfram entity, like California, USA or Germany instead of raw coordinates) and adds to a tally of site visitors by location (probably as a Wolfram Association)? Something roughly of form <| "California, USA" -> 2, "Germany" -> 1, ... |>. It doesn't have to be like this, but this just seems natural at first glance.

  2. Returns text to the user who curls it?

Example. So for example of a user does something like

curl www.wolframcloud.com/...

the response in their console should be

Welcome to my webpage!

and, internally, some Wolfram Association with the geographical data should be updated so that I can check my account to see how many people visited us/where it came from.

Attempt. The following functions seem useful: APIFunction, GeoLocation (problem: returns coordinates and not entity locations).

  • 1
    $\begingroup$ You can use HTTPRequestData inside your API code to get the metadata of the request. Also $GeoLocationCountry will give you country of the user. $\endgroup$ – dsingh Mar 9 '20 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.