Skip to main content

The HTTP API v2 is a great tool to ingest data into Amplitude via server-side. You can use Shell, HTTP, JavaScript, NodeJS, Ruby, Python, Java, and Go to hit the HTTP API v2 endpoint(https://api2.amplitude.com/2/httpapi). 

 

I will demonstrate how to ingest data from the HTTP API v2 endpoint using a curl command using Terminal on a Mac laptop. The HTTP API v2 endpoint expects the event data to be formatted in JSON. Here is an example call:

 

curl -H 'Content-Type: application/json' -d '{"api_key": "INSERT_API_KEY","events":s{"device_id":"5f9fbb3b-8b65-5a35-8ec1-699f5cfb2998", "event_type":"test_event", "event_properties": {"button_clicked_name": "Subscribe"},"user_properties": {"is_subscribed": true},"ip":"127.0.0.1"}]}' https://api2.amplitude.com/2/httpapi

 

The breakdown of the call above:

  1. You will need the API Key of your Amplitude project (only members with manager and admin permissions can see this information)

  2. The Device ID or User ID of the unique user. (In the call we are using Device ID)

  3. The name of the event in this case being “test_event” (you can choose any event name)

  4. Event and User Properties which fall under their own set of curly braces.

    1. Event Property name: “button_clicked_name”; Event Property value: “Subscribe”

    2. User Property name: “is_subscribed”; User Property value: true

  5. Notice IP Address is outside of user/event properties. This is because IP Address is an Amplitude property already.


You can find more information on the HTTP API v2 endpoint in the developers center, here.

Eddie, thanks for sharing this. As our project is using Elixir which has no provided library, using HTTP API v2 is required. However, being that we’re not using the library, a few things aren’t clear. Is event_type how the event name is specified? How do we best group events in the panel? Thanks,


Hey @trouter_space ,

Yes. The event_type field in the HTTP API will be the event name which you want to send to Amplitude.

Can you elaborate more on the “group events in the panel” part?


Hi Saish, thanks for your reply. I’m referring to “groupings” as they are suggested in the Data Taxonomy Playbook.

 

 


Hey @trouter_space ,

The event grouping/categories is something which you manage on the UI side rather than while sending raw event data. Here is how you can create those categories for your events in the Govern Feature set.

 


Reply