Retrieve access logs from the API

Modified on Wed, 06 Dec 2023 at 04:40 PM

The Fasterize API allows you to retrieve the access logs of your account for the last seven days in JSON or Apache format.


Please contact our support team to obtain the API token. Make sure you also have the configuration ID, which you can find in the dashboard URL of your configuration. For example, if the URL is https://dashboard.fasterize.com/feo/projects/64/configuration/1, the configuration ID is 1.


The URL of the Access Log API is https://api.fasterize.com/v2/configs/ $ config_id / logs .


Setting

There are various optional parameters:


  • from : seconds since the unix era
  • to : seconds since unix time
  • domain : list of targeted domains
  • onlySeoVisit : filter visitor logs from a search engine (Google, Bing, Baidu, Yandex)
  • onlySearchBot : filters logs from search engine bot traffic (Google, Bing, Baidu, Yandex)
  • format:  json or apache


Important note

In our case, the logs provided by the API come from the ingestion of CloudFront logs.

The CloudFront log retrieval system has a delay of around 30 minutes compared with real time.


In the absence of the 'from' parameter, the response returns no logs.

Feel free to adjust your parameters accordingly to obtain relevant results.


If you want to retrieve logs for the last 15 minutes:

Subtract 900 seconds (= 15 minutes) from the current timestamp.


To obtain this value, you can use a Unix timestamp converter, such as the one available at https://www.unixtimestamp.com.


Use the value as an argument to the from parameter in your URL to retrieve logs for the last 15 minutes.



API request example


# Retrieve the logs of the last fifteen minutes 

curl "https://api.fasterize.com/v2/configs/ $ config_id / logs?from=$timestamp_unix" -H "Authorization: $ myApiToken "


# Récupérer les logs de la veille

from=$(date -d "yesterday 00:00:00" '+%s')

to=$(date -d "yesterday 23:59:59" '+%s')

curl "https://api.fasterize.com/v2/configs/${configID}/logs?from=${from}&to=${to}" -H"Authorization:${token}"


Response format


Each log consists of the following fields:

  • client_ip (IPv4 address of the client),
  • content_length
  • content_type
  • domain
  • fstrz_flags (see the list of fields )
  • method
  • protocol
  • referer
  • response_time (in msec)
  • status
  • timestamp
  • url
  • user_agent
  • user_agent_class (mobile / desktop_recent / tablet / bot / old)

Example:


{
  "client_ip":"217.167.19.73",
  "content_length":40945,
  "content_type":"text/html;charset=UTF-8",
  "domain":"www.nocibe.fr",
  "fstrz_flags":"o",
  "method":"GET",
  "protocol":"http",
  "referer":"",
  "request_id":"42024b74-f79f-4173-91b5-c2c9f236c57d",
  "response_time":1.552,
  "status":"200",
  "timestamp":"2017-04-10T15:38:18.830Z",
  "url":"/giorgio-armani-si-gel-douche-p-206477",
  "user_agent":"Screaming Frog SEO Spider/7.2","user_agent_class":"desktop_recent"
}


Apache Combined Log Format


The Apache log format used is the combined format:


LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\""


This format is the only one supported by SEO analysis tools such as Screaming Frog Log Analyzer.


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article