cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know what we learned at IBC? Check out our learnings on media, remote working and more right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

#tags in the Python API

#tags in the Python API

Nprice
Explorer | Level 4
Go to solution

Hey! Is it possible to add #tags to files and/or folders using the API? I had a quick scan of the docs but couldn’t find it and the search function doesn’t work.

Anyone know?

1 Accepted Solution

Accepted Solutions

Здравко
Legendary | Level 20
Go to solution

😁 Seems, you haven't read my previous posts. Take a look on them more careful. Can you find the link? 🧐🙂

View solution in original post

9 Replies 9

Здравко
Legendary | Level 20
Go to solution

Hi @Nprice,

Take a look here: https://www.dropbox.com/developers/documentation/http/documentation#files-tags-add 😉 for API end-point.

Hope this helps.

 

For Dropbox Python SDK method take a look here.

Nprice
Explorer | Level 4
Go to solution
That’s helpful! Thank you

Maybe you can save me some time: would I get the file URL / access the file using Python and then throw each URL + tags into an API url and call it with requests?

I’m new-ish to Python so any pointers would be appreciated!

Здравко
Legendary | Level 20
Go to solution

To be honest, I'm not sure what you ask me actually. You don't need any URL neither actual file to add a tag. The only thing you need is a regular file path (aside of the tag itself), nothing else. This is the same both when using direct API endpoint access or the same through any Dropbox SDK (including Python). There is nothing Python specific. If you mean something else, clarify your question.

Lucky jump into the deep of programming. 😉

Nprice
Explorer | Level 4
Go to solution

Hey! Thank you for the reply and your help. I managed to figure out a lot of what I needed last night. 

 

What I need to do is rename + add hashtags to files based on their path. I got as far as renaming, and that's working. I was having trouble finding the method to add hashtags to a file using the Dropbox SDK.

 

This is the relevant part of the code where I have access to the file path, variables with the hashtags, and am renaming files to the convention. 

 

# Create new file name from individual tags + incremental count and add file type
new_file_name = f"{photographer_name}_{act_name}_{artist_name}_{genre}_{discipline}_{media_type}_{count}{file_type}".replace(
" ", "").replace("-", "")

# Get new file path by removing old file name from path
new_file_path = "".join(media_file.path_display.rpartition('/')[:-1])

if rename_file_check:
print(f'Renaming {media_file.name} to {new_file_name}')
# Rename file - old file path, new file path
dbx.files_move_v2(media_file.path_display, new_file_path + new_file_name)

# Increment the count to avoid overwriting
count += 1

I just wonder if there is a method similar to .files_move_v2 that I can call to add hashtags to each individual file. 

Здравко
Legendary | Level 20
Go to solution

@Nprice wrote:

...

I just wonder if there is a method similar to .files_move_v2 that I can call to add hashtags to each individual file. 


As far as I know there is not such a combined method. You need to make 2 (or more) consecutive calls to rename and to add tag(s).

Nprice
Explorer | Level 4
Go to solution

Yeah, I understand that. I'm just wondering *how* do I add the hashtags? What's the method of dropbox.Dropbox in order to do that? 

Nprice
Explorer | Level 4
Go to solution

Здравко
Legendary | Level 20
Go to solution

😁 Seems, you haven't read my previous posts. Take a look on them more careful. Can you find the link? 🧐🙂

Nprice
Explorer | Level 4
Go to solution
Oh my god. I’m an idiot. I didn’t see that second link. Thank you!!!
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Nprice Explorer | Level 4
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?