still-code/laravel-umami

Umami API wrapper for laravel

5.0.1 2024-05-03 15:17 UTC

This package is auto-updated.

Last update: 2024-05-03 15:18:33 UTC


README

68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c253230556d616d692e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d7374696c6c2d636f64652532466c61726176656c2d756d616d69267061747465726e3d627269636b57616c6c267374796c653d7374796c655f31266465736372697074696f6e3d556d616d692b4150492b777261707065722b666f722b6c61726176656c266d643d312673686f7757617465726d61726b3d3126666f6e7453697a653d313235707826696d616765733d63686172742d626172

68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7061636b6167652d6a736f6e2f762f756d616d692d736f6674776172652f756d616d693f636f6c6f723d7768697465266c6f676f436f6c6f723d7768697465266c6162656c3d556d616d69266c6f676f3d64617461253341696d616765253246706e672533426261736536342532436956424f5277304b47676f414141414e5355684555674141414751414141426b434159414141427734705655414141414358424957584d41414432454141413968414856724b393041414141475852465748525462325a30643246795a514233643363756157357263324e686347557562334a6e6d2532423438476741414348564a52454655654a7a746e5739736c566364787a2532466e7561586c396e6257753339647070576c6d57334a596b326b3468744b624773546b67455a4f6859305664526b79765146426d464b7a4c53596d4a6e777776686e426f6478416251686b595449306b6863316970675830796b534c6577467177307361754477713655437433753763385835326c336533747665253242253246743825324265556e6b253246795339716e397a6e6e3933792532465065643537764f636378346c496c6a4d77516b374163747372434747595130786a4a4b77457967557056516c554176456755726748714143554d4174344b596243574251524e344a4b64576955436166314a56535655417a7342355944645144447856597a445867546541696342726f46704733764d7a545334777a52436e314b65447a7747654178337971356b33675665416f384663785341516a4446464b56514e66417234493141566325324654253242424938426845666c587748585052555243433641472532424258774c6941685277703447566754706961687442436c3147706748253246413538727a536930616a314e585655567462533231744c6458563163546a63536f714b6f6a465969696c6d4a6959594878386e45516977636a4943414d444177774f446a49774d4d444578455325324236516c774176692532426946776f36674158516143474b4b584b6765654158554470664a2532424e52714f735737654f35755a6d6d70756261577873704b536b7549764356437046583138665054303939505430634f72557158774d53674b25324641483467496a654c71726759417579654e6746586d4b66625545704a55314f544844783455424b4a68506a462532425069344844703053467062573856786e4957367368486771634230387230434b48502532463033496564466c5a6d657a5973554d755862726b7466594c4d6a77384c4474333770547938764b466a486b4a69486d6879587a6874786d50416e25324650645a4172563636555862743279636a4969413953463862567131646c37393639456f7646356a506c4465417857597147414b334166334d643349594e472532425479356375253242694c7359686f65485a6375574c664f5a4d6746736c71566b434c4156754a5074674b71717175545973574d25324279656b6458563164556c31646e63755539344376796c49774248674766553025324635304261576c706b644854554e7847395a6d787354445a75334a6a4c6c436e6775324b794963445462714b7a6b6e6363527a6f364f69535a54506f6f6e7a394d5455334a2532467633377061536b4a4a6378653852455134444e626c4f656c58427061616c30646e62364b6c6f516e44687851714c52614b3657346c6e33355a555a6e775a755a7959626938586b354d6d54506b7356484b64506e355a34504a37726e504b346d4741495541324d5a535a5a586c34755a3836633856326b6f4f6e723635504b797370737074774550697068476f4a253242774855364d376b564b315a495631645841504b4551323976623634766b6865417149526f79504f5a53536d6c355044687730486f456972486a7825324258534353537a5a51584a4178446748585a4c6d3933373934646943416d734725324666766c78585868736b53455063727570385a694a723136365679636e4a674f51496e3151714a57317462646b4d755179736c41414e253242585a6d45764634584b356375524b55467359774f6a6f715656565632557a706b43414d41523447786a4d544f484467514741696d455a6e5a326332513234444e524b4149542532464a724c79787356465371565277436868495330744c4e6c4d4f697025324247414125324267787a374e5642714a524f547332624d424872715a584c78345555704c537a4d4e6d51512532424967566f584f6a49785a31414c4833443171316257624e6d54594846334833553139657a666676327a4d326c774a354379736e376d627237504877452532424744614e7336665030394451304d68646436314441304e55566458527a4b5a544e3938472532466977694e7a497034784357736754704a6b4273476e544a6d7447476a55314e577a627469317a637852344b7539433875336267442532425363644c713775344f734a6465477077376479376279623158387451357279374c48575037623949475a363961745971686f534563787736677a3653686f594825324225324676374d7a5855694d726a5176766d7125324253515a4925324258623239757447546c6f62322532465074766e4a665061644a624a5336694767504d766e4e6d6475574c3925324250554e44512532466e557365786f616d70434b555647372532464f345575706f6c6f253246666b6654522532424f354f32394658554c6c756c746e774e3934476e68455246507125324625324677395a6e4c4d457a35636a774546675664695a5741436f556342563943305253253246676b485a6267504d4f376d424a3733576f593168444463494156595364686552253242484257597957594c4641534a684a324635487766345839684a57475a494f6568487368597a654d64426a7943786d4d47594e635173726a766f655941574d376a686f4e6636734a6a424e5163594344734c797777443168437a654e306159686239436e3337253246535a362532464a416c50424c41765936494a494865734c4f78634546455a50723225324235253246447a4d5143364355485a353648644965596945567a45747a42316b717045754136384946776331713258416365464a4570423841396a39685745683676694d67557a4836452532423975516b72476b6a597562475779746c436f4633674c7543796d7035636f4e34454d6963676653576f694976417638507179736c6a472532466d7a5944356f34364f524a774d68623454666f76737777526b5637676234476d733777354b794c6e307a646b473566316f34435373656931596d59785a776156556b6f422532467741253242466c4253793558586759395058253242354f4d36654669485a6f6a6e4d577a336b7530777a494d5331614b5255427a674632697130253246394b45582532465a386a6674617876534b53417236426e74316a38525942646d637a512532463931253246716e514c7848253242644b253242374c583564394c526f706452393643654b397475374e3477427130566b4c4e63483570324f49434c58675765397a6d6f5a383633357a41446d37374c537571346a684e253246556c336f633958496c687772304e2532466a36425439737963596738456e4a3438557765633267457046623641565562693879736558494250445a664d794141716130695567253246384856303837506b6877425069386762253242653952253242424a2532466577692532465031347138577a422532426861366732764b66674d4f3176523476696874697a52454159634d4f4768543430586332314b42474f4b61456746253242616344426d7859764170476964533132787a526a766d4f41434b62456a7865743532494c63453335436c6c6535724b4d49676c387a524d7476536a454e61554e76653554324f494548573844625a37703646564272696b50416e3879514b53676f68743432464d4e76537a4d4e5355432532464244646a4d4d577a4b3934442532466765344869756e39634670686e54434c786d674868657832766f253242314c253242364f5a5877613470437633692532426d7347434c6e59754935656172336f5339725144556b7a35674867353252356b397353694e76417a3442374139457169456f796a4f6c415439384b57253242694659687a344b5872636257416142667143253242326e635238506652483925324665535477424f5a6e474c3077364173696b676936386c414d6d5a5741556d765135356b76415065486c45594365426b34444c777149596f53756948544b4b56576f6c2532463533516f306f3865452532426255453452545144253246536735253246613949694b5450745656454d59596b6f6c53366e37304b31302532464164533538536851566d42526b2532426933706730416c39435872583852505944444f4977314a427675694d7048304863454b7444764d376e48253246526e30326c2532466a3641563162674825324641595a46442532467862456977705135594464706c5977374347474959317844442532424435654f4a79546469364f764141414141456c46546b5375516d4343 68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7374696c6c2d636f64652f6c61726176656c2d756d616d69 68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7374696c6c2d636f64652f6c61726176656c2d756d616d69 68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f7374696c6c2d636f64652f6c61726176656c2d756d616d69 68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7374696c6c2d636f64652f6c61726176656c2d756d616d692f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65 badge.svg

Umami API wrapper for laravel

API wrapper for umami website analytics. get your statistics in the laravel app.

check out Umami, own your website analytics

Features

  • Manage websites
  • Manage users
  • query statistics stats, page views, events and metrics

Installation

You can install the package via composer:

composer require still-code/laravel-umami

Umami version:

  • for umami v1 use v4
  • for umami v2 use v5

Config

to publish the configuration file:

php artisan vendor:publish --provider="Umami\UmamiServiceProvider"

and then add these to your .env file:

UMAMI_URL=https://stats-site-com/api
UMAMI_USERNAME=username
UMAMI_PASSWORD="password"
UMAMI_WEBSITE_ID=d131d2ae-5d21-4a54-80ba-16719afedf7b

Usage

Query Stats

\Umami\Umami::query('example-site-id', 'metrics', [
    'start_at'=>today()->subDays(7),
    'end_at'=>today(),
    'type'=>'referrer',
]);

short usage for PHP 8 to get default stats for the last 7 days and without cache:

\Umami\Umami::query(siteID: 1, force: true)

Parameters

Site id

required: site id from umami server

\Umami\Umami::query('example-site-id');

Part

required: the stats part you want to get from umami,

available options : active, stats, pageviews, events, metrics

default: stats

\Umami\Umami::query('example-site-id','pageviews');

Options for Query Stats

Dates (startAt,endAt)

optional: Timestamp of starting and end date,

default: last 7 days

you can pass carbon object or timestamp in milliseconds

\Umami\Umami::query('example-site-id','metrics',[
    'startAt'=>today()->subDays(7),
    'endAt'=>now(),
]);
unit

only available on pageviews and events

optional: Time unit, available options: year, month, hour, day,

default: day

\Umami\Umami::query('example-site-id','metrics',[
    'unit'=>'year',
]);
Timezone (tz)

optional: Timezone,

only available on pageviews and events

default: config('app.timezone')

\Umami\Umami::query('example-site-id','metrics',[
    'tz'=>'America/Los_Angeles',
]);
type (for metrics only)

optional: Gets metrics for a given time range,

available options: url, referrer, browser, os, device, country, event,

default: url

\Umami\Umami::query('example-site-id','metrics',[
    'tz'=>'America/Los_Angeles',
]);

Websites

Get All websites

\Umami\Umami::websites();

Create a website

\Umami\Umami::createWebsite([
    'domain'=>'domain.ltd',
    'name'=>'user name',
]);

create a website for a diffrent user

If you want to create a website for different user then the admin user defined in the config, you need to provide the authentication for that user. this is helpful when creating a new user with a website

\Umami\Umami::createWebsite([
    'domain' => 'domain.ltd',
    'name' => 'user name',
],[
    'username' => 'otherUserName',
    'password' => 'otherPassword',
]);

Update a website

\Umami\Umami::updateWebsites('example-site-id',[
    'name'=>'user name',
]);

Delete a website

\Umami\Umami::deleteWebsite('example-site-id');

Event data

Get website event and field key record counts within a given time range

See the API documentation for details: https://umami.is/docs/api/event-data#get-/api/event-data/events

\Umami\Umami::events('example-site-id', [
    'startAt'=>today()->subDays(7),
    'endAt'=>now(),
    'event' => 'custom_event',
]);

Get website field key and value record counts within a given time range

See the API documentation for details: https://umami.is/docs/api/event-data#get-/api/event-data/fields

\Umami\Umami::event_fields('example-site-id', [
    'startAt'=>today()->subDays(7),
    'endAt'=>now(),
]);

Users

Get all users

\Umami\Umami::users();

Create a user

\Umami\Umami::createUser('username','password');

Update a user

\Umami\Umami::updateUser(1,[
    'username'=>'username',
    'password'=>'password',
]);

Delete a user

\Umami\Umami::deleteUser(2);

More details

Please check out Umami website for more information.

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.