---
title: "TIL: Measuring API Response Times With curl -w"
description: curl -w prints DNS, connect, TLS and response times after every request, so you can profile API latency from the terminal without another tool.
canonical: https://lukeocodes.dev/til-curl-w-response-times
type: article
locale: en_GB
published: 2026-05-05T00:00:00.000Z
modified: 2026-05-05T00:00:00.000Z
authors:
  - Luke Oliff
section: TIL
tags:
  - TIL
  - Engineering
  - APIs
feed: https://lukeocodes.dev/rss.xml
search: https://lukeocodes.dev/search.json?q={query}
schema:
  - "@context": https://schema.org
    "@graph":
      - "@type": Organization
        "@id": https://ably.com/#organization
        name: Ably
        url: https://ably.com
      - "@type": WebSite
        "@id": https://lukeocodes.dev/#website
        url: https://lukeocodes.dev
        name: Luke Oliff
        alternateName: lukeocodes
        inLanguage: en
        publisher:
          "@id": https://lukeocodes.dev/authors/luke#person
        description: Personal blog and writing by Luke Oliff — developer relations, voice AI, developer experience.
        potentialAction:
          - "@type": SearchAction
            target:
              "@type": EntryPoint
              urlTemplate: https://lukeocodes.dev/blog/search?q={search_term_string}
            query-input: required name=search_term_string
      - "@type": Person
        "@id": https://lukeocodes.dev/authors/luke#person
        name: Luke Oliff
        url: https://lukeocodes.dev/authors/luke
        description: Staff engineer and Staff Tech Lead for Developer Experience at Ably. Writing about developer relations, AI, and the voice industry, from the UK.
        mainEntityOfPage: https://lukeocodes.dev/authors/luke
        givenName: Luke
        familyName: Oliff
        image: https://lukeocodes.dev/authors/luke.jpg
        jobTitle: Staff Tech Lead, Developer Experience
        worksFor:
          "@id": https://ably.com/#organization
        sameAs:
          - https://www.linkedin.com/in/lukeocodes
          - https://github.com/lukeocodes
          - https://bsky.app/profile/lukeocodes.dev
          - https://x.com/lukeocodes
          - https://hashnode.com/@lukeocodes
          - https://dev.to/lukeocodes
        knowsAbout:
          - Developer Relations
          - Developer Experience
          - Voice AI
          - Text-to-Speech
          - Answer Engine Optimisation
          - Search Engine Optimisation
          - Open Source
          - Developer Tooling
          - API Design
          - Speech-to-Text
          - Voice Agents
          - Community Building
        knowsLanguage:
          - English
        nationality: British
        alumniOf:
          - "@type": Organization
            name: The Open University
  - "@context": https://schema.org
    "@graph":
      - "@type": Organization
        "@id": https://ably.com/#organization
        name: Ably
        url: https://ably.com
      - "@type": Person
        "@id": https://lukeocodes.dev/authors/luke#person
        name: Luke Oliff
        url: https://lukeocodes.dev/authors/luke
        description: Staff engineer and Staff Tech Lead for Developer Experience at Ably. Writing about developer relations, AI, and the voice industry, from the UK.
        mainEntityOfPage: https://lukeocodes.dev/authors/luke
        givenName: Luke
        familyName: Oliff
        image: https://lukeocodes.dev/authors/luke.jpg
        jobTitle: Staff Tech Lead, Developer Experience
        worksFor:
          "@id": https://ably.com/#organization
        sameAs:
          - https://www.linkedin.com/in/lukeocodes
          - https://github.com/lukeocodes
          - https://bsky.app/profile/lukeocodes.dev
          - https://x.com/lukeocodes
          - https://hashnode.com/@lukeocodes
          - https://dev.to/lukeocodes
        knowsAbout:
          - Developer Relations
          - Developer Experience
          - Voice AI
          - Text-to-Speech
          - Answer Engine Optimisation
          - Search Engine Optimisation
          - Open Source
          - Developer Tooling
          - API Design
          - Speech-to-Text
          - Voice Agents
          - Community Building
        knowsLanguage:
          - English
        nationality: British
        alumniOf:
          - "@type": Organization
            name: The Open University
      - "@type": BlogPosting
        "@id": https://lukeocodes.dev/til-curl-w-response-times#article
        headline: "TIL: Measuring API Response Times With curl -w"
        alternativeHeadline: "TIL: Measuring API Response Times With curl -w"
        description: curl -w prints DNS, connect, TLS and response times after every request, so you can profile API latency from the terminal without another tool.
        datePublished: 2026-05-05T00:00:00.000Z
        dateModified: 2026-05-05T00:00:00.000Z
        url: https://lukeocodes.dev/til-curl-w-response-times
        mainEntityOfPage: https://lukeocodes.dev/til-curl-w-response-times
        inLanguage: en
        author:
          - "@id": https://lukeocodes.dev/authors/luke#person
        isPartOf:
          "@id": https://lukeocodes.dev/#website
        keywords: TIL, Engineering, APIs
        articleSection: TIL
        abstract: A slow API feels slow. curl -w tells you exactly where the time goes.
        speakable:
          "@type": SpeakableSpecification
          cssSelector:
            - .post-tldr
            - h1
        image: https://lukeocodes.dev/og.png?h=TIL%3A+Measuring+API+Response+Times+With+curl+-w&d=curl+-w+prints+DNS%2C+connect%2C+TLS+and+response+times+after+every+request%2C+so+you+can+profile+API+latency+from+the+terminal+without+another+tool.&e=Writing
        wordCount: 171
        timeRequired: PT1M
        publisher:
          "@id": https://ably.com/#organization
      - "@type": BreadcrumbList
        itemListElement:
          - "@type": ListItem
            position: 1
            name: Home
            item: https://lukeocodes.dev
          - "@type": ListItem
            position: 2
            name: Writing
            item: https://lukeocodes.dev/blog
          - "@type": ListItem
            position: 3
            name: "TIL: Measuring API Response Times With curl -w"
            item: https://lukeocodes.dev/til-curl-w-response-times
---

[Luke Oliff.](/)

- [Blog](/blog)
- [CV](/cv)
- [Uses](/uses)
- [User manual](/user-manual)
- [Living with ADHD](/living-and-working-with-adhd)
- [RSS](/rss.xml)

[Luke Oliff · Writing](/blog)

# TIL: Measuring API Response Times With curl -w

May 2026 · [TIL](/blog/category/til) · 1 min read · [Luke Oliff](/authors/luke)

A slow API feels slow. curl -w tells you exactly where the time goes.

```bash
curl -w "\ntime_total: %{time_total}s\ntime_connect: %{time_connect}s\ntime_starttransfer: %{time_starttransfer}s\n" \
  -X POST https://api.example.com/v1/listen \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/audio.wav"}'
```

The -w flag prints timing variables after the response. time_total is the full request duration. time_connect is the TCP handshake. time_starttransfer is when the first byte of the response arrives.

```bash
curl -w "@timing-format.txt" -o /dev/null -s https://api.example.com/v1/models
```

Put the format string in a file. The @filename syntax reads it from there. Keep it in your dotfiles for consistent measurements.

```bash
# timing-format.txt
\n
HTTP code: %{http_code}\n
DNS: %{time_namelookup}s\n
Connect: %{time_connect}s\n
TLS: %{time_appconnect}s\n
First byte: %{time_starttransfer}s\n
Total: %{time_total}s\n
```

Breakdown of every phase. DNS lookup, TLS handshake, and response time are measured separately.

### Can I log timings to a file?

Use the -w flag combined with -o to write the response body to a file and -w to append timings to a log file.

```bash
curl -w "..." -o /dev/null -s https://api.example.com/v1/listen >> timing.log
```

[← Newer: How voice AI SDKs handle things REST clients never have to](/what-makes-voice-ai-sdks-different)

[All posts](/blog) →

## Search this site

`GET https://lukeocodes.dev/search.json?q=<words>` returns matching posts as JSON, each with its page URL and its markdown URL. Add `&limit=<1-50>` for more than 10. How it works: [/blog/search](https://lukeocodes.dev/blog/search.md).

```sh
curl "https://lukeocodes.dev/search.json?q=developer+relations"
```

---

© 2026 Luke Oliff. Posts live at the root of this site.

- [GitHub](https://github.com/lukeocodes)
- [LinkedIn](https://www.linkedin.com/in/lukeocodes)
- [X](https://x.com/lukeocodes)
- [Bluesky](https://bsky.app/profile/lukeocodes.dev)
- [Email](mailto:luke@lukeoliff.com)
- [RSS](/rss.xml)

## Cookies

This site sets one analytics cookie, from Google Analytics, and only in a browser that accepts the cookie banner. A client that does not run scripts sets no cookies, so there is nothing to accept or decline here.

[Cookie policy](/cookies)
