Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/boo1ean/compete
PHP wrapper for Compete API.
https://github.com/boo1ean/compete
Last synced: 30 days ago
JSON representation
PHP wrapper for Compete API.
- Host: GitHub
- URL: https://github.com/boo1ean/compete
- Owner: boo1ean
- Created: 2012-08-29T07:47:30.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2012-08-29T19:43:17.000Z (about 12 years ago)
- Last Synced: 2024-04-14T18:41:56.719Z (7 months ago)
- Language: PHP
- Homepage:
- Size: 102 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
PHP wrapper for [Compete API](https://www.compete.com/developer/).
## Examples of usage
Wrapper has generic method `get`. You can retrieve any kind of metric via this method:
```php
get('SOME_DOMAIN', 'METRIC_CODE');// Get the number of people who visited a domain
$data = $compete->get('facebook.com', 'uv');// Get the ranking of the domain by total number of unique visitors
$data = $compete->get('google.com', 'rank');
```Here is list of available metrics:
Metric NameBasic or All-Acces?descriptionmetric codeUnique VisitorsBasicThe number of people who visited a domainuvVisitsBasicThe number of separate visits made to a domain by all unique visitorsvisRankBasicThe ranking of the domain by total number of unique visitorsrankPage ViewsAll-AccessThe number of times a page has been loaded from a domainpvAverage StayAll-AccessThe average number of seconds that a visit lasts avgstayVisits/PersonAll-AccessThe average number of times each unique visitor visits the domainvppPages/VisitAll-AccessThe average number of pages displayed during a visitppvAttentionAll-AccessThe percent of total minutes spent by all US users on the internet that were spent on this domainatt Reach (daily)All-AccessThe percent of all US users on the internet that had at least one visit to this domain by dayreachdAttention (daily)All-AccessThe percent of total minutes spent by all US users on the internet that were spent on this domain by dayattdGenderAll-AccessThe split between males and females visiting a domaingenAgeAll-AccessPercent of unique visitors in various age bracketsageIncomeAll-AccessPercent of unique visitors in various income bracketsincAlso you can use specific methods for getting data:
```php
uniqueVisitors('example.com');// The number of separate visits made to a domain by all unique visitors
$compete->visits('example.com');// The ranking of the domain by total number of unique visitors
$compete->rank('example.com');// The number of times a page has been loaded from a domain
$compete->pageViews('example.com');// The average number of seconds that a visit lasts
$compete->averageStay('example.com');// The average number of times each unique visitor visits the domain
$compete->visitsPerson('example.com');// The average number of pages displayed during a visit
$compete->pagesVisit('example.com');// The percent of total minutes spent by all US users
// on the internet that were spent on this domain
$compete->attention('example.com');// The percent of all US users on the internet that
// had at least one visit to this domain by day
$compete->dailyReach('example.com');// The percent of total minutes spent by all US users
// on the internet that were spent on this domain by day
$compete->dailyAttention('example.com');// The split between males and females visiting a domain
$compete->gender('example.com');// Percent of unique visitors in various age brackets
$compete->age('example.com');// Percent of unique visitors in various income brackets
$compete->income('example.com');
```## Response format
Return values have same format but decoded via `json_decode` (wrapped in `stdClass`).
Trends field name depends on specific metric.
```json
{
"status": "OK",
"data": {
"trends": {
"uv": [
{"date": "200906", "value": 90714948},
{"date": "200907", "value": 98292793},
{"date": "200908", "value": 103509116},
...
]
},
"trends_low_sample": false,
"query_cost": 13,
"trends_frequency": "monthly"
}
}
```## Errors
If there is some error in request wrapper will throw `CompeteException`.## TODO
* Add support for additional request params(date, graph, ...)