# New endpoint: project task counts

**URL:** <https://forum.asana.com/t/new-endpoint-project-task-counts/57032>\
**Category:** Platform News\
**Tags:** api, projects\
**Created:** [6 August 2019 19:37 UTC](https://forum.asana.com/t/new-endpoint-project-task-counts/57032 "2019-08-06T19:37:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joe\_Trollo](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/joe_trollo/32/4025_2.png) [@Joe\_Trollo](https://forum.asana.com/u/Joe_Trollo)\
**Post date:** [6 August 2019 19:37 UTC](https://forum.asana.com/t/new-endpoint-project-task-counts/57032/1 "2019-08-06T19:37:52Z")

</div>

Hello all! With the growing set of high-level reporting and planning features Asana has been adding to our web app (timeline, portfolios, workload) we’ve decided to bring some additional high-level reporting functionality to the API: **project task counts**. When you view a list of projects in a portfolio or view a project’s “Progress” tab, you can see a count of complete and incomplete tasks and milestones in that project, and those counts are now in the API!

Specifically, by hitting `GET /projects/<project-gid>/task_counts` you can get six different counts for that project:

```auto
{
  "num_tasks": 150,
  "num_incomplete_tasks": 100,
  "num_completed_tasks": 50,
  "num_milestones": 10,
  "num_incomplete_milestones": 7,
  "num_completed_milestones": 3
}

```

A few things to note about this endpoint:

- **All fields are opt-in.** You’ll need to use the [`opt_fields` parameter](https://asana.com/developers/documentation/getting-started/input-output-options) to select which counts you want. Like the rest of our API, we encourage you to select only the fields you need.
- **This endpoint has a separate rate limit.** You will be limited to 60 requests per minute, similar to the search API. These fields also count fairly high against our cost limits, so you should only opt-in to the fields you truly need.
- **Milestones are included in task counts.** Milestones are a subtype of tasks, and so `num_tasks` and other task counts also include counts of milestones. In the above example, there are 150 tasks in the project, of which 140 have `resource_subtype: "default_task"` and 10 have `resource_subtype: "milestone"`.

Take a look at [our docs](https://asana.com/developers/api-reference/projects#get-task-counts) for more information. Happy reporting!

> **[Build an app with Asana](https://developers.asana.com/docs#asana-projects)**
>
> Learn the basics of Asana's developer platform

---

<div class="post-metadata">

**Author:** ![Joe\_Trollo](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/joe_trollo/32/4025_2.png) [@Joe\_Trollo](https://forum.asana.com/u/Joe_Trollo)\
**Post date:** [6 August 2019 19:38 UTC](https://forum.asana.com/t/new-endpoint-project-task-counts/57032/2 "2019-08-06T19:38:05Z")

</div>

Pinned on 6 August 2019 19:38 UTC



---

<div class="post-metadata">

**Author:** ![Frederic\_Malenfant](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/frederic_malenfant/32/8358_2.png) [@Frederic\_Malenfant](https://forum.asana.com/u/Frederic_Malenfant)\
**Post date:** [29 August 2019 14:12 UTC](https://forum.asana.com/t/new-endpoint-project-task-counts/57032/3 "2019-08-29T14:12:23Z")

</div>

That’s great news, will be useful to show our customers why the app seems slow fetching data, when we know that a project have 25000 tasks.  
Can these new fields be returned by you while paging, on the first page?  
I mean, if I query for /projects/xyz/tasks, when I receive the first page with the “paging offset”, can we also receive the “total count” to have an idea of how many page we’ll need to query?  
If not, I’ll certainly add a query to these new task\_counts when I detect a huge project that needs paging.

---

<div class="post-metadata">

**Author:** ![Joe\_Trollo](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/joe_trollo/32/4025_2.png) [@Joe\_Trollo](https://forum.asana.com/u/Joe_Trollo)\
**Post date:** [5 September 2019 00:54 UTC](https://forum.asana.com/t/new-endpoint-project-task-counts/57032/4 "2019-09-05T00:54:00Z")

</div>

Unfortunately, we cannot make these counts part of our pagination systems. They only apply to these few specific categories (completed/incomplete/total tasks/milestones in a project) and would not work when, for example, using `modified_since` to filter the tasks, or when making queries for other kinds of objects in the API.

---

<div class="post-metadata">

**Author:** ![anon48069021](https://luna1.co/8d76cd.png) [@anon48069021](https://forum.asana.com/u/anon48069021)\
**Post date:** [22 January 2020 10:07 UTC](https://forum.asana.com/t/new-endpoint-project-task-counts/57032/5 "2020-01-22T10:07:44Z")

</div>

For some reason I’ve not been able to get this to work no matter what I include in the opt\_fields as part of the GET request. Does anyone have a working example? Thanks!

---

<div class="post-metadata">

**Author:** ![anon48069021](https://luna1.co/8d76cd.png) [@anon48069021](https://forum.asana.com/u/anon48069021)\
**Post date:** [25 February 2020 15:17 UTC](https://forum.asana.com/t/new-endpoint-project-task-counts/57032/6 "2020-02-25T15:17:53Z")

</div>

Realised I hadn’t posted an update after solving this issue, it was super simple and just down to me not reading properly…  
The following GET request works fine!  
[https://app.asana.com/api/1.0/projects/](https://app.asana.com/api/1.0/projects/)\<project\_gid\>/task\_counts?opt\_fields=num\_tasks

---

<div class="post-metadata">

**Author:** ![Ronald\_Findling](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/ronald_findling/32/31535_2.png) [@Ronald\_Findling](https://forum.asana.com/u/Ronald_Findling)\
**Post date:** [1 October 2020 18:11 UTC](https://forum.asana.com/t/new-endpoint-project-task-counts/57032/8 "2020-10-01T18:11:21Z")

</div>

_Reposted as it’s own thread in the API forum [How to use the Task Count Endpoint for Projects in the java client library](https://forum.asana.com/t/how-to-use-the-task-count-endpoint-for-projects-in-the-java-client-library/99471)_

I struggle creating this request with the java client-lib `"com.asana:asana:0.10.1"` - I would assume that I just need to do the following:

```auto
client.projects.getTaskCountsForProject(projectId).option("fields", "num_tasks").execute()

```

But this always returns me an empty JSON object `{}` -what am I missing here?

- The docu for the endpoint [Get task count of a project](https://developers.asana.com/docs/get-task-count-of-a-project)
- The docu on input output options (as the fields all need to be opted in) [Input/output options](https://developers.asana.com/docs/input-output-options)

Debugging the client I see the following:

- The LowLevelHttpRequest uses the wrong url [https://app.asana.com/api/1.0/projects/](https://app.asana.com/api/1.0/projects/)/task\_counts?opt\_pretty=false&limit=50  
at [1]
- This should be because in [2] the url doesn’t contain the opt\_fields see [3]

But I’m still not sure what I might have configured wrong - any help would be very much appreciated.

> **References**
>
> - [1] `com.google.http-client/google-http-client/1.20.0/5140e4d6fc293ede7dee965e8f3426d3e9e3d0c0/google-http-client-1.20.0-sources.jar!/com/google/api/client/http/HttpRequest.java:862`
> - [2] `com.asana/asana/0.10.1/fea2bd16f4426fad8ae4aef42bfde7c7b03692ea/asana-0.10.1-sources.jar!/com/asana/Client.java:201`
> - [3] `url = { "opt_pretty" -> {Boolean@3443} false, "limit" -> {Integer@3444} 50`

---

<div class="post-metadata">

**Author:** ![davidperez](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/davidperez/32/142228_2.png) [@davidperez](https://forum.asana.com/u/davidperez)\
**Post date:** [17 November 2020 07:43 UTC](https://forum.asana.com/t/new-endpoint-project-task-counts/57032/9 "2020-11-17T07:43:47Z")

</div>

Nice!  
Do we have this method for users?
