Event API

By using our Event API you can create custom events and store event data on our servers. You can use custom events to send push notifications. For example, you can create FacebookShareEvent and send notification when user clicks facebook share button.

PARAMETERS:

X-netmera-api-key :  Netmera API Key. You can get it from the application’s overview page on netmera.com

et : Name of the fired event.

iid : Unique installation id of the device that is generated by Netmera SDK.

data : Custom data that is sent with fired event.

cf : Custom fields that will be used to matched with the custom fields saved during push registration.

Fire Event

To fire an event with custom attributes add required parameters (et and iid) and post it to the following URL. You can add key-value pairs into the data json.

curl -X POST \
-H "X-netmera-api-key: ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"et": "${CUSTOM_EVENT_NAME}",
	"iid": "${INSTALLATION_ID}",
	"data": {"key1":"value1","key2":"value2"}
}' \
https://api.netmera.com/event/1.0/fireEvent

If the event is fired successfully, you will get the code 1000 and message OK as a response.

{ "message" : "OK", "code" : 1000 }

In case of exception occurs while creating event, following response message will be sent. For example if API Key is invalid then you will get following response.

{ "message" : "API key is null or empty!", "code" : 2010 }
Bulk Fire Event

By using the following code you can create several events in one request. Data format of the events is same as in the fireEvent.

curl -X POST \
-H "X-netmera-api-key: ${API_KEY}" \
-H "Content-Type: application/json" \
-d '[
    {
        "et": "${CUSTOM_EVENT_NAME}",
        "iid": "${INSTALLATION_ID}",
        "data": {
        "key1":"value1",
        "key2":"value2"
        }
    },
    {
        "et": "${CUSTOM_EVENT_NAME}",
        "iid": "${INSTALLATION_ID}",
        "data": {
        "key1":"value1",
        "key2":"value2"
        }
    }
]' \
https://api.netmera.com/event/1.0/fireEvent/bulk
Fire Event With Custom Fields

If you do not know or can’t access the installation id of a device, you can find users by using the custom fields as shown below and fire event. With this method, you can also fire events for multiple users that matched with the custom query.

curl -X POST \
-H "X-netmera-api-key: ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
    "et": "${CUSTOM_EVENT_NAME}",
    "cf": {
        "key1":"value1",
        "key2":"value2"
    },
    "data": {
        "key1":"value1",
        "key2":"value2"
}
}' \
https://api.netmera.com/event/1.0/fireEvent
Bulk Fire Event By Custom Fields

By using the following code you can create several events in one request. Data format of the events is same as in the fireEvent by custom fields.

curl -X POST \
-H "X-netmera-api-key: ${API_KEY}" \
-H "Content-Type: application/json" \
-d '[
    {
        "et": "${CUSTOM_EVENT_NAME}",
        "cf": {
               "key1":"value1",
                    "key2":"value2"
        },
        "data": {
        "key1":"value1",
        "key2":"value2"
        }
    },
    {
        "et": "${CUSTOM_EVENT_NAME}",
        "cf": {
               "key1":"value1",
                    "key2":"value2"
        },
        "data": {
        "key1":"value1",
        "key2":"value2"
        }
    }
]' \
https://api.netmera.com/event/1.0/fireEvent/bulk

March 31, 2015 / parag

Recent Blog Posts
ROI based app marketing for your business
App Indexing: some insights
Categories