2

I am a complete novice when it comes to coding and would really appreciate your help in a project.

I want to pull data in Excel from an API offered by a website (resource URL: http://api.opensignal.com/v2/networkrank.json).

Can you please advice how should I go about it. Or could you please help with a sample code.

Many thanks

2
  • Including some of the work you've done so far will help others with a starting point for their advice. Commented Dec 9, 2014 at 7:20
  • Chuck, fair point - unfortunately I am still figuring out how to begin Commented Dec 9, 2014 at 7:34

2 Answers 2

5

I made VBA-Web (Excel-REST) for accessing webservices and APIs with Excel. While I encourage you to look into tutorials on how to perform web requests with Excel (look for XMLHTTPRequest), I've found it to be a little tricky to get started, especially if you're new to programming, so here is some sample code based on OpenSignal's example:

Sub GetNetworkRank(Latitude As Double, Longitude As Double)
    ' Create client for executing requests
    Dim Client As New WebClient
    Client.BaseUrl = "http://api.opensignal.com/v1/"

    ' Create specific request
    Dim Request As New WebRequest
    Request.Resource = "networkrank.json"
    ' Request.Method = WebMethod.HttpGet is default
    ' Request.Format = WebFormat.Json is default

    Request.AddQuerystringParam "lat", Latitude
    Request.AddQuerystringParam "lng", Longitude

    ' distance=20 -> 20 km around lat-lng -> 40km x 40km bounding box
    Request.AddQuerystringParam "distance", 20

    ' network_id=3 -> 3G networks
    Request.AddQuerystringParam "network_id", 3

    Request.AddQuerystringParam "apikey", "YOUR_API_KEY"

    ' Get response from request
    Set Response = Client.Execute(Request)
    ' -> GET http://api.opensignal.com/v1/networkrank.json?lat=...&lng=...&...

    If Response.StatusCode = 200 Then
        ' Get network rank
        ' (json response is automatically parsed)
        Response.Data("networkRank")("...")
    Else
        Debug.Print "Error: " & Response.StatusCode & " " & Response.Content
    End If
End Sub
Sign up to request clarification or add additional context in comments.

Comments

0

First pick a langage. If you are a novice in programming, you can give Python a try. It is not that hard to get started. Just follow a good Getting Started Guide.

Then find the libraries you need to connect to your systems. For example:

Try basic things (simple GET on the API, simple write in the Excel document). Make it work. Iterate.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.