# Call REST API directly from browser

**URL:** <https://community.particle.io/t/call-rest-api-directly-from-browser/908>\
**Category:** uncategorized\
**Created:** [December 22, 2013, 5:02am UTC](https://community.particle.io/t/call-rest-api-directly-from-browser/908 "2013-12-22T05:02:17Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/dave/32/181_2.png) [@Dave](https://community.particle.io/u/Dave)\
**Post date:** [December 22, 2013, 2:52pm UTC](https://community.particle.io/t/call-rest-api-directly-from-browser/908/8 "2013-12-22T14:52:09Z")

</div>

Hey @benddennis ,

You are right in that the URL itself is correct, but the method in the http request needs to be a “post” request. When you open a url in a browser directly, those are “get” requests. (web developers or experienced users can skip this post)

The reason to distinguish between Get / Put / Post / Delete requests has to do with desired side effects. Calling a function on your core has the potential to have side effects, where reading a variable is more like asking for a resource, etc. The downside of this is it’s a bit trickier to play with unless you’re using a web development tool that lets you specify the http request method.

If you were using node.js, here is some (really ugly example for calling a function on your core through the API)

```javascript
var http = require('http');
var request = require('request');

var function_name = "led";
var function_params = "l2,HIGH";
var core_id = "your core id";
var access_token = "your token";

request({
	uri: "https://api.spark.io/v1/devices/" + core_id + "/" + function_name,
	method: "POST",
	form: {
		arg: function_params,
		access_token: access_token
	},
	json: true
},
function (error, response, body) {
	console.log(error, response, body);
});

```

(note, I haven’t tested this code, it’s more for reference!)

---

_[View the full topic](https://community.particle.io/t/call-rest-api-directly-from-browser/908)._
