# Connect directly to a Spark Photon REST API

**URL:** <https://community.particle.io/t/connect-directly-to-a-spark-photon-rest-api/14007>\
**Category:** Cloud\
**Created:** [July 31, 2015, 5:59pm UTC](https://community.particle.io/t/connect-directly-to-a-spark-photon-rest-api/14007 "2015-07-31T17:59:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![johan](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@johan](https://community.particle.io/u/johan)\
**Post date:** [July 31, 2015, 5:59pm UTC](https://community.particle.io/t/connect-directly-to-a-spark-photon-rest-api/14007/1 "2015-07-31T17:59:41Z")

</div>

I connected my newly arrived Photon’s to my WIFI accespoint and followed the tutorials. I created the REST example from [http://docs.particle.io/photon/examples/](http://docs.particle.io/photon/examples/). Which is working fine with the following URL:  
[https://api.particle.io/v1/devices/your-device-ID-goes-here/led?access\_token=your-access-token-goes-here](https://api.particle.io/v1/devices/your-device-ID-goes-here/led?access_token=your-access-token-goes-here)

However I would like to connect directly to the Photon without an internet connection. So something like http://PHOTON\_HOSTNAME/… I searched through the community and found this thread: [Tutorial: Local Cloud 1st Time instructions [01 Oct 15]](https://community.particle.io/t/tutorial-local-cloud-1st-time-instructions-20-march-15/5589/123) . Is that the solution for my problem? Or is there an easier solution?

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [July 31, 2015, 6:18pm UTC](https://community.particle.io/t/connect-directly-to-a-spark-photon-rest-api/14007/2 "2015-07-31T18:18:21Z")

</div>

The local cloud should work. TCP/IP and UDP are also available. The local cloud should be the easiest transition though, depending on what you’re trying to achieve,

---

<div class="post-metadata">

**Author:** ![johan](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@johan](https://community.particle.io/u/johan)\
**Post date:** [August 1, 2015, 11:36am UTC](https://community.particle.io/t/connect-directly-to-a-spark-photon-rest-api/14007/3 "2015-08-01T11:36:42Z")

</div>

Ok, I just want to call a REST endpoint on the Photon to turn some LED’s on or off. So there is no way to directly call the Photon for instance with an IP address? It’s necessary to use the local cloud option?

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [August 20, 2015, 4:11am UTC](https://community.particle.io/t/connect-directly-to-a-spark-photon-rest-api/14007/4 "2015-08-20T04:11:21Z")

</div>

Hi @johan, you don’t need the local cloud to implement a HTTP server on the photon. All that’s needed is a WiFi connection to a router.

In coming months we will implement AP mode on the photon, so the Photon itself will be the access point and your devices can connect directly to it without needing an intervening router.

Cheers 😄  
mat.

---

<div class="post-metadata">

**Author:** ![johan](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@johan](https://community.particle.io/u/johan)\
**Post date:** [September 16, 2015, 3:35pm UTC](https://community.particle.io/t/connect-directly-to-a-spark-photon-rest-api/14007/5 "2015-09-16T15:35:45Z")

</div>

I’ve setup the localcloud and I can see my Photon (actually the spark-server app mentions “Core online!” :)).

However I can’t connect to the Photon. I have uploaded the led example [https://docs.particle.io/guide/getting-started/examples/photon/#control-leds-over-the-39-net](https://docs.particle.io/guide/getting-started/examples/photon/#control-leds-over-the-39-net) to the Photon. It works when I use the Particle cloud, but how do I connect to the Photon with the local cloud?

What URL should I use instead of the URL for the Particle cloud: ‘[https://api.particle.io/v1/devices/your-device-ID-goes-here/led?access\_token=your-access-token-goes-here](https://api.particle.io/v1/devices/your-device-ID-goes-here/led?access_token=your-access-token-goes-here)’?

---

<div class="post-metadata">

**Author:** ![johan](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@johan](https://community.particle.io/u/johan)\
**Post date:** [September 16, 2015, 5:53pm UTC](https://community.particle.io/t/connect-directly-to-a-spark-photon-rest-api/14007/6 "2015-09-16T17:53:20Z")

</div>

Ok, I'm a bit further, apparently there is something wrong with my access token. But I have no idea what.

I figured out my acces token:

> $ particle config identify  
> Current profile: localcloud\_profile  
> Using API: [http://192.168.178.15:8080](http://192.168.178.15:8080)  
> Access token: XYZ

I start 'node main.js' and in another window call the API:

```auto
$ curl http://192.168.178.15:8080/v1/devices?access_token=c442acbe41aaa40bdd708ecc444297d0e06a572f
{
  "code": 400,
  "error": "invalid_grant",
  "error_description": "The access token provided is invalid."
}

```

The output of the local server is:

```auto
Your server IP address is: 192.168.178.15
server started { host: 'localhost', port: 5683 }
Connection from: 192.168.178.20, connId: 1
on ready { coreID: 'ABC',
  ip: '192.168.178.20',
  product_id: 6,
  firmware_version: 65535,
  cache_key: '_0' }
Core online!
192.168.178.15 - - [Wed, 16 Sep 2015 17:50:19 GMT] "GET /v1/devices?access_token=XYZ HTTP/1.1" 400 109 "-" "curl/7.30.0"

```

Any idea what I'm doing wrong?

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [September 16, 2015, 6:13pm UTC](https://community.particle.io/t/connect-directly-to-a-spark-photon-rest-api/14007/7 "2015-09-16T18:13:27Z")

</div>

> [@johan](#):
>
> apparently there is something wrong with my access token.

Nah, your accesstoken is perfectly fine. For the Particle Cloud. Since you're running the local cloud, you shouldn't be using that one though.

Have a read through these topics:

> [@Tutorial: Local Cloud 1st Time instructions \[01 Oct 15\]](https://community.particle.io/t/tutorial-local-cloud-1st-time-instructions-20-march-15/5589):
>
> This will guide you through on how to Setup the Local cloud and use it with Particle-CLI after a successful installation. Before you proceed, make sure you fired up particle-server successfully at least once. We will need the server public keys generated on 1st run later. \*\*NOTE: \*\* This will point the Particle-CLI to the local cloud and you will not be able to use features available on the spark cloud 1.) We will now create a new server profile on Particle-CLI using the command: part…

> [@Local Cloud on Raspberry Pi](https://community.particle.io/t/local-cloud-on-raspberry-pi/5708):
>
> Hello community! I have started documenting the steps i have taken to setup a Raspberry Pi with Local cloud from scratch! Not really an experienced user of linux so if you have any suggests on what should be added in for configuration, let me know! The public repo is here: [https://github.com/kennethlimcp/book-rpi-lc](https://github.com/kennethlimcp/book-rpi-lc) The tutorial will appear here: [http://kennethlimcp.gitbooks.io/spark-local-cloud-on-raspberry-pi/content/](http://kennethlimcp.gitbooks.io/spark-local-cloud-on-raspberry-pi/content/) Thanks and have a great weekend! wink

> [@Tutorial: Local Cloud on Windows \[25 July 2014\]](https://community.particle.io/t/tutorial-local-cloud-on-windows-25-july-2014/5949):
>
> Hello there! Interested in running your own spark Local cloud but the github repo looks intimidating? Here’s a step by step guide written just for you smile It is highly recommended that you do not skip the steps or deviate from the instructions as installing on Windows is a challenging due to the number of dependencies! 1.) DFU-util Follow the instructions here to install DFU-util driver: [https://community.spark.io/t/tutorial-installing-dfu-driver-on-windows/3518](https://community.spark.io/t/tutorial-installing-dfu-driver-on-windows/3518) Download DFU-util fr…

---

<div class="post-metadata">

**Author:** ![johan](https://avatars.discourse-cdn.com/v4/letter/j/dec6dc/32.png) [@johan](https://community.particle.io/u/johan)\
**Post date:** [September 16, 2015, 6:37pm UTC](https://community.particle.io/t/connect-directly-to-a-spark-photon-rest-api/14007/8 "2015-09-16T18:37:19Z")

</div>

Thanks for the tip, but I already followed those tutorials. However I repeated some of the steps and now it’s working. Apparently I forget one or more of the steps. It would be nice if there was a simpler setup without so many steps :).
