API's: Do you need more examples?

Comments

10 comments

  • Avatar
    Ross

    I would like more examples

    0
    Comment actions Permalink
  • Avatar
    Brazuca1331

    Improvement suggestions:

    •  /flows/query endpoint - if `ts` is supposed to be the epoch timestamp, its value is coming over as the time the api call was made not the timestamp of the flow. 
    • /alarm/list - date filter would be good.
    0
    Comment actions Permalink
  • Avatar
    Michael Bierman

    @Brazuc1331 I'm not seeing ts being the api call time. If I query the last say, 10 minutes I get 

    1662144594.688
    1662144594.686
    1662144594.685
    1662144592.667

    Alarm list can be filtered already. There are some examples https://help.firewalla.com/hc/en-us/articles/5345330648083-MSP-API-Getting-Started-#filterbytime 

    0
    Comment actions Permalink
  • Avatar
    Brazuca1331

    Thanks, you're right..it's not the API call timestamp, however it's also not the flow timestamp which I imagine is what it should be. 

    In regards to the alarm list filtering, that's done after the call. I was looking for something to add to the API call to filter on the spot rather than piping to jq to do it.

    0
    Comment actions Permalink
  • Avatar
    Michael Bierman

    I think the ts is the time that the flow occurred. 

    With the IFTTT, and I believe Slack you can already filter. I think it is typical for APIs to leave it to the "app" (whatever is using the API) to do the filtering. After all, the API will be called by something. 

    0
    Comment actions Permalink
  • Avatar
    Brazuca1331

    Yup, not a big deal for the API filter. I can do the filtering from the calling app like you mentioned. The TS on the other hand is not the flow's timestamp...that's what I'm trying to say. Converting the epoch TS you'll see that they all are a few seconds from when the API call was executed.

    0
    Comment actions Permalink
  • Avatar
    Michael Bierman

    Interesting. 

    So in MSP itself, the same API call does result in "ts" being the time of the flow. But if I call it locally you seem to be right. I'm not sure what is happening.

    0
    Comment actions Permalink
  • Avatar
    Michael Bierman

    @Brazuca1331 So here is what the problem is.

    Something like the following will work as expected: 

    curl --request POST  \
    --url 'https://woodstock.firewalla.net/v1/flows/query' \
    --header 'Authorization: Token [redacted]' \
    --header 'Content-Type: application/json' \
    --data '{
      "start":1662418680,
      "end":1662418740,
        "limit":200,
        "filters": [
        {
          "key": "device",
          "values": [
            "BigMac Ethernet 🖥"
          ]
        }
      ]
    }'  

    However, if you leave out the header:

    --header 'Content-Type: application/json' \

    as I did initially, you will get a result, but it will be wrong. Anytime there is a filter or time range that header must be included. This was a pilot error on my part nothing wrong with the API.  Sorry about that.

    0
    Comment actions Permalink
  • Avatar
    Brazuca1331

    Thanks for that Michael, for some reason i was using "earliest" and "latest" instead of "start" and "end" as the request body...that was my issue. Your help was awesome!

    1
    Comment actions Permalink
  • Avatar
    TR

    We support the API github concept and are looking forward to contributing.

    0
    Comment actions Permalink

Please sign in to leave a comment.