Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Position of lists via API api.trello.com/1/lists

Christopher Andersson July 3, 2019

The position I post to the API api.trello.com/1/lists is returned differently to me than what I pass in.

Example:

const options = { 
method: "POST",
uri: `https://api.trello.com/1/lists`,
qs: {
name: "some list name",
idBoard: boardId,
pos: 1.0,
key: key,
token: token
}

};

Trello returns: pos: 1.125

{
"id": "9dkd03m4405da5d3",
"name": "some list name",
"closed": false,
"idBoard": "99akd03020494kd",
"pos": 1.125,
"limits": {}
}

Sometimes Trello will return something that's not even close to what I passed in.

For example I pass in a position of 9.0 and I get 2056 in return!

2 answers

0 votes
August Mohr November 13, 2020

I have also been wanting to create new lists in specific positions within a board.

I definitely was confused by the difference between the position shown in the UI, which is simply a counting number, starting at 1 and going up to the number of lists on the board, and the .pos value in the API, which is a floating point number often going up to six digits plus three decimal digits. I also notices that Trello seems fond of adding a .125 (1/8) to whole number values.

Using the UI number in the API was not working for me because it turned out that the list at UI position #1 had a .pos value of 2056. I was telling the API that I wanted the new List all the way down at position #10 and it would still create it at the far left.

Then I found an article that explained the difference. Floating point numbers are used so that Trello can insert new items many, many times while still leaving the existing .pos values intact, rather than recalculating .pos values each and every time you add anything.

At first I thought I had to find the position values of both the list to the left and the list to the right of the new list and calculate a position value someplace in between. But it turned out, at least in my case, to be much easier than that because Trello does all that invisibly.

I simply get the .pos position of the list to the left of my desired location and then use that value as the position of the new list. When adding a new list, Trello automatically places it to the right of the existing list at that given position. That's all I needed.

Because I know Trello can recalculate the .pos values any time I add something, in fact I am counting on it, I do not save those values from one session to the next nor do I assume that any of the .pos values stay the same after I add something. I expect the returned .pos value to be different from the submitted .pos value.

This applies to the order of cards in a list too.

I hope this helps.

0 votes
Iain Dooley
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 4, 2019

@Christopher Andersson Yeah the position is represented differently internally than the numbers you pass in.

If you want to find out the position of a list, you'd need to grab all the visible lists in the board, sort by the position attribute and then find out where it sits.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events