# API Setup

**URL:** <https://forum.mautic.org/t/api-setup/2194>\
**Category:** Product Support\
**Created:** [August 17, 2015, 7:39pm UTC](https://forum.mautic.org/t/api-setup/2194 "2015-08-17T19:39:21Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![dzawacki](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@dzawacki](https://forum.mautic.org/u/dzawacki)\
**Post date:** [August 17, 2015, 7:39pm UTC](https://forum.mautic.org/t/api-setup/2194/1 "2015-08-17T19:39:21Z")

</div>

Okay, I need some hand holding since I don’t usually work with APIs in my programming (trying to immerse myself in the Mautic API though).  
  
  
  
I started by downloading the API from [https://github.com/mautic/api-library](https://github.com/mautic/api-library) and uploaded it to a folder where I want to start testing it out. I followed instructions I found on [this blog](http://johnlinhart.com/blog/implementing-mautic-api). However, when I try to load the PHP page I created with the updated code from step 3.3, I get this error:

Quote:

**Fatal error:** Class 'ApiAuth' not found in **/htdocs/path/to/file/mautic\_test.php** on line **28**

  
Line 28 contains:

Code:

$auth = ApiAuth::initiate($settings);

  
So, it's clear I didn't include a file, but I'm really unsure which file I need to include. Any direction will help.

---

<div class="post-metadata">

**Author:** ![dzawacki](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@dzawacki](https://forum.mautic.org/u/dzawacki)\
**Post date:** [August 17, 2015, 7:39pm UTC](https://forum.mautic.org/t/api-setup/2194/2 "2015-08-17T19:39:21Z")

</div>

Okay, I need some hand holding since I don’t usually work with APIs in my programming (trying to immerse myself in the Mautic API though).

I started by downloading the API from [https://github.com/mautic/api-library](https://github.com/mautic/api-library) and uploaded it to a folder where I want to start testing it out. I followed instructions I found on [this blog](http://johnlinhart.com/blog/implementing-mautic-api). However, when I try to load the PHP page I created with the updated code from step 3.3, I get this error:

> [@](#):
>
> Fatal error: Class ‘ApiAuth’ not found in /htdocs/path/to/file/mautic\_test.php on line 28

Line 28 contains: `$auth = ApiAuth::initiate($settings);`

So, it’s clear I didn’t include a file, but I’m really unsure which file I need to include. Any direction will help.

---

<div class="post-metadata">

**Author:** ![chad.windnagle](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@chad.windnagle](https://forum.mautic.org/u/chad.windnagle)\
**Post date:** [August 18, 2015, 11:58am UTC](https://forum.mautic.org/t/api-setup/2194/3 "2015-08-18T11:58:43Z")

</div>

You ran the composer install commands - does the autoload.php file exist?

---

<div class="post-metadata">

**Author:** ![dzawacki](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@dzawacki](https://forum.mautic.org/u/dzawacki)\
**Post date:** [August 18, 2015, 6:23pm UTC](https://forum.mautic.org/t/api-setup/2194/4 "2015-08-18T18:23:51Z")

</div>

I went with step 2, as I’m not sure Composer is set up on my host.

---

<div class="post-metadata">

**Author:** ![chad.windnagle](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@chad.windnagle](https://forum.mautic.org/u/chad.windnagle)\
**Post date:** [August 18, 2015, 6:58pm UTC](https://forum.mautic.org/t/api-setup/2194/5 "2015-08-18T18:58:57Z")

</div>

The API tester is very much a developer oriented tool, I would consider composer a requirement, or at least the easiest way of getting it running. @escopecz might be able to offer some additional notes on trying to do it without though.

---

<div class="post-metadata">

**Author:** ![mbabker](https://avatars.discourse-cdn.com/v4/letter/m/0ea827/32.png) [@mbabker](https://forum.mautic.org/u/mbabker)\
**Post date:** [August 18, 2015, 7:12pm UTC](https://forum.mautic.org/t/api-setup/2194/6 "2015-08-18T19:12:59Z")

</div>

If you don’t have Composer installed, the library also has an autoloader which can make sure classes get loaded in. You’ll need to call `include_once '/path/to/lib/Mautic/AutoLoader.php';` in your code before trying to call the Mautic API classes.

---

<div class="post-metadata">

**Author:** ![dzawacki](https://avatars.discourse-cdn.com/v4/letter/d/9d8465/32.png) [@dzawacki](https://forum.mautic.org/u/dzawacki)\
**Post date:** [August 18, 2015, 8:29pm UTC](https://forum.mautic.org/t/api-setup/2194/7 "2015-08-18T20:29:35Z")

</div>

At the top of the file, I’ve tried making the call to the file located in the Mautic install (Mautic/app/autoload.php) and I still get the same error.

Is this the correct file to link to? I couldn’t find any other files with Autoload in the name.

I also tried to install via Composer, but my host is giving me an error when I run the command from Composer to install.

---

<div class="post-metadata">

**Author:** ![chad.windnagle](https://avatars.discourse-cdn.com/v4/letter/c/7feea3/32.png) [@chad.windnagle](https://forum.mautic.org/u/chad.windnagle)\
**Post date:** [August 18, 2015, 8:48pm UTC](https://forum.mautic.org/t/api-setup/2194/8 "2015-08-18T20:48:16Z")

</div>

Looks like we don’t include it in the repo anymore because we use composer.

To create your own autoloader you’l have to copy the contents from this file:

[https://github.com/mautic/mautic-joomla/blob/master/lib/Mautic/AutoLoader.php](https://github.com/mautic/mautic-joomla/blob/master/lib/Mautic/AutoLoader.php)

And create the lib/Mautic/Autoload.php file yourself, and then use the require statement to include it in your project.

---

<div class="post-metadata">

**Author:** ![trops](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/trops/32/3998_2.png) [@trops](https://forum.mautic.org/u/trops)\
**Post date:** [October 12, 2015, 4:42pm UTC](https://forum.mautic.org/t/api-setup/2194/9 "2015-10-12T16:42:12Z")

</div>

I used composer, and it still says ApiAuth not found. The file exists, I can see it. I ran the install for composer as well.

---

<div class="post-metadata">

**Author:** ![trops](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/trops/32/3998_2.png) [@trops](https://forum.mautic.org/u/trops)\
**Post date:** [October 12, 2015, 4:45pm UTC](https://forum.mautic.org/t/api-setup/2194/10 "2015-10-12T16:45:08Z")

</div>

Gotta use MauticAuthApiAuth and it works. Might want to update the Readme in the api-library.

Im using OAuth1a with no callback, and it says “Callback not valid”. I need to have NO Callback when using the API. I know this is possible, just don’t know how to do it with Mautic Auth…

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [October 14, 2015, 8:22am UTC](https://forum.mautic.org/t/api-setup/2194/11 "2015-10-14T08:22:58Z")

</div>

@trops could you send a PR to the api-library repo with your suggestions?

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [February 2, 2020, 10:57pm UTC](https://forum.mautic.org/t/api-setup/2194/12 "2020-02-02T22:57:46Z")

</div>


