Skip to content

trendoscope-algorithms/Tradingview-Access-Management

Repository files navigation

Trendoscope

Tradingview-Access-Management

CodeFactor
This project provides restful API access to manage tradingview script access management. This is intended to be used by vendors along with appropriate security and other workflow management tools for automation of access management.

Installation

Follow below steps to install and run the API service

Clone repo in replit

Goto Replit Page: https://replit.com/@trendoscope/Tradingview-Access-Management

Update Replit environment variables

Only environment variables to be updated are:
  • username - Your tradingview username
  • password - Your tradingview password
Please note that access management apis will only work if you have Premium Tradingview subscription.

Run the repl

Just run the repl and your services are up and running. You will get the hostname on top right part of the project dashboard. Hostname will be of the format,
https://Tradingview-Access-Management.[YOUR_REPL_ACCOUN].repl.co

Usage

Once up and running, you will be able to use following calls to manage Tradingview access.

GET /validate/{username}

Can be used to validate username. This can be handy operation to execute before trying to execute access management for the user. If user is not valid, we can stop the workflow then and there.

  • Payload - None
  • Headers - None
  • Returns - JSON output with following information:
    1. validUser - Can be true or false. Tells whether username passed is valid or not.
    2. verifiedUserName - returns the exact username as in Tradingview records (along with matching case). If validUser is false, this field will also have blank value.
{
    "validuser": true,
    "verifiedUserName": "Trendoscope"
}

GET /access/{username}

This method can be used to get the current access level of user for particular publications identified by pine_ids

  • Payload - Json Payload containing list of pine ids
    1. pine_ids - Array of pine ids. Pine ids are backend unique ids for each script. We can get these ids from browser developer console when script is loaded or when access methods are performed on the tradingview UI. Please note, only Pine Ids for scripts which belong to your account will work in this way. You will not be able to control the access to scripts which are not yours.
    2. {
          "pine_ids" : ["PUB;3be120ba74944ca7b32ad644f40aaff2", "PUB;2cb3ba84ce4443049f21659a3b492779"]
      }
      
  • Headers - None
  • Returns - JSON output array with following information:
    1. pine_id - Pine publication id which is sent as input to the API request
    2. username - Username against which the operation is performed.
    3. hasAccess - true if user already has access to script. false otherwise
    4. noExpiration - true if user has non expiring access to script. false otherwise
    5. currentExpiration - applicable only if hasAccess is true and noExpiration is false. Ignore otherwise.
[
    {
        "pine_id": "PUB;3be120ba74944ca7b32ad644f40aaff2",
        "username": "trendoscope",
        "hasAccess": false,
        "noExpiration": false,
        "currentExpiration": "2022-08-17 06:27:49.067935+00:00"
    },
    {
        "pine_id": "PUB;2cb3ba84ce4443049f21659a3b492779",
        "username": "trendoscope",
        "hasAccess": false,
        "noExpiration": false,
        "currentExpiration": "2022-08-17 06:27:49.196514+00:00"
    }
]

DELETE /access/{username}

This method can be used to remove the current access level of user for particular publications identified by pine_ids

  • Payload - Json Payload containing list of pine ids
    1. pine_ids - Array of pine ids. Pine ids are backend unique ids for each script. We can get these ids from browser developer console when script is loaded or when access methods are performed on the tradingview UI. Please note, only Pine Ids for scripts which belong to your account will work in this way. You will not be able to control the access to scripts which are not yours.
    2. {
          "pine_ids" : ["PUB;3be120ba74944ca7b32ad644f40aaff2", "PUB;2cb3ba84ce4443049f21659a3b492779"]
      }
      
  • Headers - None
  • Returns - JSON output array with following information:
    1. pine_id - Pine publication id which is sent as input to the API request
    2. username - Username against which the operation is performed.
    3. hasAccess - true if user had access to script before removing access. false otherwise
    4. noExpiration - true if user had non expiring access to script before removing access. false otherwise
    5. status - Status of the remove operation
[
    {
        "pine_id": "PUB;3be120ba74944ca7b32ad644f40aaff2",
        "username": "trendoscope",
        "hasAccess": true,
        "noExpiration": true,
        "currentExpiration": "2022-08-17 06:28:49.655286+00:00",
        "status": "Success"
    },
    {
        "pine_id": "PUB;2cb3ba84ce4443049f21659a3b492779",
        "username": "trendoscope",
        "hasAccess": true,
        "noExpiration": true,
        "currentExpiration": "2022-08-17 06:28:49.923866+00:00",
        "status": "Success"
    }
]

POST /access/{username}

This method can be used to add/update current access level of user for particular publications identified by pine_ids.

  • Payload - Json Payload containing list of pine ids
    1. pine_ids - Array of pine ids. Pine ids are backend unique ids for each script. We can get these ids from browser developer console when script is loaded or when access methods are performed on the tradingview UI. Please note, only Pine Ids for scripts which belong to your account will work in this way. You will not be able to control the access to scripts which are not yours.
    2. duration - String representing duration. Example, "7D" = 7 days, "2M" = 2 months, "1L" = Lifetime etc
    3. {
          "pine_ids" : ["PUB;3be120ba74944ca7b32ad644f40aaff2", "PUB;2cb3ba84ce4443049f21659a3b492779"],
          "duration" : "7D"
      }
      
  • Headers - None
  • Returns - JSON output array with following information:
    1. pine_id - Pine publication id which is sent as input to the API request
    2. username - Username against which the operation is performed.
    3. hasAccess - true if user already has access to script. false otherwise
    4. noExpiration - true if user has non expiring access to script. false otherwise
    5. currentExpiration - applicable only if hasAccess is true and noExpiration is false. Ignore otherwise.
    6. expiration - New expiration applied after applying access update.
    7. status - Status can be Success, Failure, or Not Applied. Not Applied will be returned if user already has lifetime access to given script and no further addition is possible.
[
    {
        "pine_id": "PUB;3be120ba74944ca7b32ad644f40aaff2",
        "username": "trendoscope",
        "hasAccess": true,
        "noExpiration": true,
        "currentExpiration": "2022-09-17T06:28:25.933303+00:00",
        "expiration": "2022-09-17T06:28:25.933303+00:00",
        "status": "Success"
    },
    {
        "pine_id": "PUB;2cb3ba84ce4443049f21659a3b492779",
        "username": "trendoscope",
        "hasAccess": true,
        "noExpiration": true,
        "currentExpiration": "2022-09-17T06:28:26.191805+00:00",
        "expiration": "2022-09-17T06:28:26.191805+00:00",
        "status": "Success"
    }
]

Contributions & Thanks

If you found this project interesting or useful, create accounts with my referral links:

Profiles

Links

https://linktr.ee/tscope

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published