# API name conflict in local server?

**URL:** <https://community.particle.io/t/api-name-conflict-in-local-server/9396>\
**Category:** General\
**Created:** [January 16, 2015, 12:12pm UTC](https://community.particle.io/t/api-name-conflict-in-local-server/9396 "2015-01-16T12:12:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuanetking](https://avatars.discourse-cdn.com/v4/letter/y/dc4da7/32.png) [@yuanetking](https://community.particle.io/u/yuanetking)\
**Post date:** [January 16, 2015, 12:12pm UTC](https://community.particle.io/t/api-name-conflict-in-local-server/9396/1 "2015-01-16T12:12:02Z")

</div>

Hi Guys,

I just reviewed the local server page.

> **[particle-iot/spark-server](https://github.com/particle-iot/spark-server)**
>
> spark-server - An API compatible open source server for interacting with devices speaking the spark-protocol

i found below API:

#Get Core attributes  
GET /v1/devices/:coreid  
########################  
#Get all my Events  
GET /v1/devices/events

I just confuse for how the server distinguish to the ‘events’ or ‘:coreid’ ?

---

<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:** [January 16, 2015, 12:58pm UTC](https://community.particle.io/t/api-name-conflict-in-local-server/9396/2 "2015-01-16T12:58:07Z")

</div>

The colon in `:coreid` indicates an ID, which can then be handled with appropriate code, whereas `events` is ‘merely’ a URL to which you can navigate. (about 50% sure that’s correct ;))

---

<div class="post-metadata">

**Author:** ![yuanetking](https://avatars.discourse-cdn.com/v4/letter/y/dc4da7/32.png) [@yuanetking](https://community.particle.io/u/yuanetking)\
**Post date:** [January 16, 2015, 1:18pm UTC](https://community.particle.io/t/api-name-conflict-in-local-server/9396/3 "2015-01-16T13:18:00Z")

</div>

events is not just a url which used for navigate, it will subscribe the properly events. ''events" will be identify as a coreid, if it be routed after “:coreid”, i suppose.

---

<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:** [January 16, 2015, 1:52pm UTC](https://community.particle.io/t/api-name-conflict-in-local-server/9396/4 "2015-01-16T13:52:40Z")

</div>

I see your point now.  
I renamed my Core to `events` with the coreID `53ff6d065075535140381687`;

* * *

`https://api.spark.io/v1/devices/53ff6d065075535140381687?access_token=ACCESS_TOKEN_HERE`  
would give me the Core attributes correctly like so:

```auto
{
  "id": "53ff6d065075535140381687",
  "name": "events",
  "connected": true,
  "variables": {
    "temp": "double",
    "humi": "double"
  },
  "functions": [
    "temp"
  ],
  "cc3000_patch_version": "1.29"
}

```

* * *

`https://api.spark.io/v1/devices/events?access_token=ACCESS_TOKEN_HERE`  
Would subscribe me to all my events (notice different coreIDs):

```auto
:ok

event: pubdata
data: {"data":"{\"t\":17.20,\"h\":53.30}","ttl":"60","published_at":"2015-01-16T13:56:22.652Z","coreid":"53ff6d065075535140381687"}

event: color_values
data: {"data":"{\"r\": 0, \"g\": 134248145, \"b\": 536891240}","ttl":"1","published_at":"2015-01-16T13:57:01.969Z","coreid":"50ff77065067545650270487"}

```

* * *

If you’re planning on using the core’s name to access it, then yes, I guess you could say there’s a conflict, in the unlikely event that someone would call their Core “events”. I personally would stick to the coreID to indentify my Core since that is not likely to change, whereas the name is.  
Perhaps @dave can elaborate this in a bit more detail(?)

---

<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:** [January 16, 2015, 3:50pm UTC](https://community.particle.io/t/api-name-conflict-in-local-server/9396/5 "2015-01-16T15:50:24Z")

</div>

Sounds right, if you’re using the name “events”, it’ll probably match a wildcard route. 🙂

Thanks,  
David

---

<div class="post-metadata">

**Author:** ![yuanetking](https://avatars.discourse-cdn.com/v4/letter/y/dc4da7/32.png) [@yuanetking](https://community.particle.io/u/yuanetking)\
**Post date:** [January 16, 2015, 3:50pm UTC](https://community.particle.io/t/api-name-conflict-in-local-server/9396/6 "2015-01-16T15:50:31Z")

</div>

@Moors7 , thanks your reply,

I mean , not using the core name , but only use coreid , I just tested, this will related to the setting order.

There are code in the main.js:

> eventsV1.loadViews(app);  
> api.loadViews(app);

if we alternate the load order to below , then the issue will comes out.

> api.loadViews(app);  
> eventsV1.loadViews(app);

Express, will check if the the /\*\* name is belong to the routers first , then variables, So it will realted to the setting order .

Please , forgive me for my question if it is so easy, I am almost a fresher for nodejs.
