Get a sheet URL with the Sheet ID [API]

Options
Christian G.
Christian G. ✭✭✭✭✭✭

I'm using Python and I want to get the URL of a sheet if I know its sheet ID.

I try to create a list of hyperlink thru the API.

I already have access to the sheet and I could copy the url by hand, but that is not the point.

Best Answer

  • Lucas Rayala
    Lucas Rayala ✭✭✭✭✭✭
    Answer ✓
    Options

    Try this:

    import smartsheet

    # Set your Smartsheet API access token

    access_token = 'YOUR_ACCESS_TOKEN'

    # Set the sheet ID for which you want to retrieve the URL

    sheet_id = 'YOUR_SHEET_ID'

    # Initialize the Smartsheet client

    client = smartsheet.Smartsheet(access_token)

    # Get the sheet details using the sheet ID

    sheet = client.Sheets.get_sheet(sheet_id)

    # Retrieve the URL from the sheet details

    sheet_url = sheet.permalink

    print(f'The URL of the sheet is: {sheet_url}')

Answers