Skip to content

Commit 9cd0d34

Browse files
authored
Merge pull request #2599 from segmentio/DOC-470-improvements-to-http-api-docs
HTTP API/Spec Field ID Updates [DOC-470]
2 parents daf298a + aa6a74a commit 9cd0d34

File tree

4 files changed

+24
-25
lines changed

4 files changed

+24
-25
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<tr>
22
<td markdown="span">`anonymousId`</td>
3-
<td markdown="span">*optional if userID is set instead*</td>
3+
<td markdown="span">*required; optional if `userID` is set instead*</td>
44
<td markdown="span">String</td>
5-
<td markdown="span">A pseudo-unique substitute for a User ID, for cases when you don't have an absolutely unique identifier. A userId or an anonymousId is required.
6-
5+
<td markdown="span">A pseudo-unique substitute for a User ID, for cases when you don't have an absolutely unique identifier. A `userId` or an `anonymousId` is required.
6+
77
See the [Identities docs](/docs/connections/spec/identify#identities) for more details.
88
</td>
99
</tr>

src/_includes/content/spec-field-user-id.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<tr>
22
<td markdown="span">`userId`</td>
3-
<td markdown="span">*optional if anonymousID is set instead*</td>
3+
<td markdown="span">*required; optional if `anonymousID` is set instead*</td>
44
<td markdown="span">String</td>
55
<td markdown="span">Unique identifier for the user in your database.
66

7-
A userId or an anonymousId is required.
7+
A `userId` or an `anonymousId` is required.
88

99
See the [Identities docs](/docs/connections/spec/identify#identities) for more details.
1010
</td>

src/connections/sources/catalog/libraries/server/http-api/index.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,32 @@ title: HTTP Tracking API Source
33
redirect_from: '/connections/sources/catalog/libraries/server/http/'
44
id: iUM16Md8P2
55
---
6-
The Segment HTTP Tracking API lets you record analytics data from any website or application. The requests hit our servers, and we route your data to any destination you want!
6+
The Segment HTTP Tracking API lets you record analytics data from any website or application. The requests hit Segment servers, Segment routes your data to any destination you want.
77

8-
Segment has native [sources](/docs/connections/sources/) for most use cases (Javascript, iOS, etc.) that are all built for high-performance and are open-source. But sometimes you may want to send to the HTTP API directly—that's what this reference is for.
8+
Segment has native [sources](/docs/connections/sources/) for most use cases (like JavaScript and iOS) that are all built for high-performance and are open-source. But sometimes you may want to send to the HTTP API directly—that's what this reference is for.
99

1010
## Headers
1111

1212
### Authentication
1313

1414
Authenticate to the Tracking API by sending your project's **Write Key** along with a request.
15-
Authentication uses HTTP Basic Auth, which involves a 'username:password' that is base64 encoded and prepended with the string 'Basic '.
15+
Authentication uses HTTP Basic Auth, which involves a `username:password` that is base64 encoded and prepended with the string `Basic`.
1616

1717
In practice that means taking a Segment source **Write Key**,`'abc123'`, as the username, adding a colon, and then the password field is left empty. After base64 encoding `'abc123:'` becomes `'YWJjMTIzOg=='`; and this is passed in the authorization header like so: `'Authorization: Basic YWJjMTIzOg=='`.
1818

1919
### Content-Type
2020

21-
In order to send data to our HTTP API, a content-type header must be set to `'application/json'`.
21+
To send data to Segment's HTTP API, a content-type header must be set to `'application/json'`.
2222

2323
## Errors
2424

25-
We currently return a `200` response for all API requests so debugging should be done in the Segment Debugger. The only exception is if the request is too large / JSON is invalid it will respond with a `400`.
26-
27-
We're hard at work surfacing more errors and more helpful responses to our users. If you have any suggestions, [let us know](https://segment.com/help/contact/)!
25+
Segment returns a `200` response for all API requests so debugging should be done in the Segment Debugger. The only exception is if the request is too large / JSON is invalid it will respond with a `400`.
2826

27+
Segment welcomes feedback on API responses and error messages. [Reach out to support](https://segment.com/help/contact/) with any requests or suggestions you may have.
2928

3029
## Rate Limits
3130

32-
There is no hard rate limit at which point Segment will drop your data. We ask that if you need to import at a rate exceeding 500 requests per second, [contact us](https://segment.com/help/contact/) first. Requests include batches sent with the [batch method](#batch), which means you can send a large batch of events inside of a single request.
31+
There is no hard rate limit at which point Segment will drop your data. [Contact support](https://segment.com/help/contact/) if you need to import at a rate exceeding 500 requests per second. Requests include batches sent with the [batch method](#batch), which means you can send a large batch of events inside of a single request.
3332

3433
## Max Request Size
3534

@@ -39,7 +38,7 @@ There is a maximum of `32KB` per normal API request. The `batch` API endpoint a
3938

4039
`identify` lets you tie a user to their actions and record traits about them. It includes a unique User ID and any optional traits you know about them.
4140

42-
We recommend calling `identify` a single time when the user's account is first created, and only identifying again later when their traits change.
41+
Segment recommends calling `identify` a single time when the user's account is first created, and only identifying again later when their traits change.
4342

4443
Example `identify` call:
4544

@@ -71,15 +70,15 @@ This call is identifying the user by their unique User ID (the one you know them
7170
{% include content/spec-field-user-id.md %}
7271
</table>
7372

74-
Find details on the **identify method payload** in our [Spec](/docs/connections/spec/identify/).
73+
Find details on the **identify method payload** in the [Segment Spec](/docs/connections/spec/identify/).
7574

7675
## Track
7776

78-
`track` lets you record the actions your users perform. Every action triggers what we call an "event", which can also have associated properties.
77+
`track` lets you record the actions your users perform. Every action triggers an "event", which can also have associated properties.
7978

8079
You'll want to track events that are indicators of success for your site, like **Signed Up**, **Item Purchased** or **Article Bookmarked**.
8180

82-
To get started, we recommend tracking just a few important events. You can always add more later!
81+
To get started, try tracking just a few important events. You can always add more later.
8382

8483
Example `track` call:
8584

@@ -254,7 +253,7 @@ For more details on the `alias` call and payload, check out our [Spec](/docs/con
254253

255254
You can import historical data by adding the `timestamp` argument to any of your method calls. This can be helpful if you've just switched to Segment.
256255

257-
Historical imports can only be done into destinations that can accept historical timestamped data. Most analytics tools like Mixpanel, Amplitude, Kissmetrics, etc. can handle that type of data just fine. One common destination that does not accept historical data is Google Analytics since their API cannot accept historical data.
256+
Historical imports can only be done into destinations that can accept historical timestamped data. Most analytics tools like Mixpanel, Amplitude, and Kissmetrics can handle that type of data just fine. One common destination that does not accept historical data is Google Analytics since their API cannot accept historical data.
258257

259258
**Note:** If you're tracking things that are happening right now, leave out the `timestamp` and our servers will timestamp the requests for you.
260259

@@ -377,13 +376,13 @@ POST https://api.segment.io/v1/identify
377376
}
378377
```
379378

380-
In this case, we're specifying that we want this identify to only go to Mixpanel and Kissmetrics. `'All': false` says that no destination should be enabled unless otherwise specified. `'Mixpanel': true` turns on Mixpanel, etc.
379+
`'All': false` says that no destination should be enabled unless otherwise specified. `'Mixpanel': true` turns on Mixpanel, `"Kissmetrics": true,` turns on Kissmetrics, and so on.
381380

382-
Destination flags are **case sensitive** and match [the destination's name in the docs](/docs/connections/destinations/catalog/) (i.e. "AdLearn Open Platform", "awe.sm", "MailChimp", etc.).
381+
Destination flags are **case sensitive** and match [the destination's name in the docs](/docs/connections/destinations/catalog/) (i.e. "AdLearn Open Platform", "awe.sm", "MailChimp", and so on).
383382

384383
**Note:**
385384

386-
- Available at the business level, filtering track calls can be done right from the Segment UI on your source schema page. We recommend using the UI if possible since it's a much simpler way of managing your filters and can be updated with no code changes on your side.
385+
- Available at the business level, filtering track calls can be done right from the Segment UI on your source schema page. Segment recommends using the UI if possible since it's a much simpler way of managing your filters and can be updated with no code changes on your side.
387386

388387
- If you are on a grandfathered plan, events sent server-side that are filtered through the Segment dashboard will still count towards your API usage.
389388

@@ -401,6 +400,6 @@ When sending a HTTP call from a user's device, you can collect the IP address by
401400

402401
1. Double check that you've set up the library correctly.
403402

404-
2. Make sure that you're calling one of our API methods once the library is successfully installed—[`identify`](#identify), [`track`](#track), etc.
403+
2. Make sure that you're calling one of our API methods once the library is successfully installed—[`identify`](#identify), [`track`](#track), and so on.
405404

406405
{% include content/troubleshooting-server-integration.md %}

src/connections/spec/identify.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Here's the payload of a typical `identify` call with most [common fields](/docs/
3838
}
3939
```
4040

41-
And here's the corresponding Javascript event that would generate the above payload:
41+
And here's the corresponding JavaScript event that would generate the above payload:
4242

4343
```js
4444
analytics.identify("97980cfea0067", {
@@ -113,7 +113,7 @@ The Anonymous ID can be any pseudo-unique identifier. For example, on your serve
113113

114114
**Note:** Our [browser and mobile libraries](/docs/connections/sources/) **automatically** use Anonymous IDs under the covers to keep track of users as they navigate around your website or app, so you don't need to worry about them when using those libraries.
115115

116-
Here's an example of a Javascript event for an anonymous user:
116+
Here's an example of a JavaScript event for an anonymous user:
117117

118118
```js
119119
analytics.identify({
@@ -238,4 +238,4 @@ Reserved traits we've standardized:
238238

239239
**Note:** You might be used to some destinations recognizing special traits by slightly different names. For example, Mixpanel recognizes a `$created` trait when the user's account was first created, while Intercom recognizes the same trait as `created_at` instead. Luckily, you don't have to worry about those inconsistencies. Just pass us `createdAt`. **We'll handle all of the destination-specific conversions for you automatically.** Same goes for the rest of the reserved traits.
240240

241-
**You can pass these reserved traits using camelCase or snake_case**, so in Javascript you can match the rest of your camel-case code by sending `firstName`, while in Ruby you can match your snake-case code by sending `first_name`. That way the API never seems alien to your code base. Keep in mind that not all destinations support these reserved traits, so sending these traits in camelCase and snake_case can result in two sets of traits in other destinations.
241+
**You can pass these reserved traits using camelCase or snake_case**, so in JavaScript you can match the rest of your camel-case code by sending `firstName`, while in Ruby you can match your snake-case code by sending `first_name`. That way the API never seems alien to your code base. Keep in mind that not all destinations support these reserved traits, so sending these traits in camelCase and snake_case can result in two sets of traits in other destinations.

0 commit comments

Comments
 (0)