Google Analytics API

Make a simple endpoints of your website daily. monthly pageviews and users data to make simple and nice interface about your website analytics.

Overview

Base Endpoint

For Google Analytics API, the format of your endpoint ⤵️

https://v1.nocodeapi.com/<username>/ga/<token>

- username- your nocodeapi username.

- token- every api have unique token. See your API card when you setup API.

API Error Codes:

If your query fails, API will return a 3-digit error-code and info as plain text

Error response example: If you provide a invalid key or do not send one, you will be responded with Unauthorised Access in below format.

{
    "error": 1,
    "code": 401,
    "info": "Unauthorized"
}

Common API Errors:

Code Info [affected API endpoints]
200 (OK)Standard response for successful GET, POST, UPDATE & DELETE
400 (Bad Request)Error response when creating (POST) or updating (UPDATE, DELETE).
401 (Unauthorized)Error response when wrong or invalid API key
402 (Payment Required)Returned if pro feature is tried to be accessed from free account
403 (Forbidden)Error response when action is forbidden by the user (API owner)
404 (No such route) Route is not valid or query params is in-valid.
429 (Rate limit exceeded)Your API request limit exceeded per month.
500 (Server error)Server error

API Endpoints

Analytics Data

Make the GET request on below endpoint to get Analytics Data for diffrent metrics.

https://v1.nocodeapi.com/<username>/ga/<token>?metrics=pageviews&startDate=7daysAgo

- Request Parameters:

ObjectDescription
metrics[Required] pageviews or users
startDate[Required] Start date of your data range 1daysAgo, 7daysAgo, 14daysAgo, 28daysAgo, 30daysAgo, or Ex: YYYY-MM-DD.
endDate[Optional] End date of your data range. by default is 'today'
dimensions[Optional] date, browser, country, fullReferrer, pagePath, or deviceCategory, default value is date
orderBys[Optional] descending or ascending. default value no sorting

- Code Examples

const axios = require('axios');
    
axios({
    method: 'get',
    url: 'https://v1.nocodeapi.com/<username>/ga/<token>', 
    params: {metrics: 'pageviews',startDate: '7daysAgo'},
}).then(function (response) {
        // handle success
        console.log(response);
}).catch(function (error) {
        // handle error
        console.log(error);
})

More Endpoints Examples

- Pageviews

https://v1.nocodeapi.com/<username>/ga/<token>?metrics=pageviews&startDate=7daysAgo

- Users

https://v1.nocodeapi.com/<username>/ga/<token>?metrics=users&startDate=7daysAgo&dimensions=date

- Browsers

https://v1.nocodeapi.com/<username>/ga/<token>?metrics=pageviews&startDate=7daysAgo&dimensions=browser

- Devices

https://v1.nocodeapi.com/<username>/ga/<token>?metrics=pageviews&startDate=7daysAgo&dimensions=deviceCategory

- Country

https://v1.nocodeapi.com/<username>/ga/<token>?metrics=pageviews&startDate=7daysAgo&dimensions=country

- Source

https://v1.nocodeapi.com/<username>/ga/<token>?metrics=pageviews&startDate=7daysAgo&dimensions=source

- Top Pages

https://v1.nocodeapi.com/<username>/ga/<token>?metrics=pageviews&startDate=7daysAgo&dimensions=pagePath