GithubHelp home page GithubHelp logo

elandyg / tradingview-access-management Goto Github PK

View Code? Open in Web Editor NEW

This project forked from trendoscope-algorithms/tradingview-access-management

0.0 0.0 0.0 22.77 MB

Shell 0.06% C++ 0.77% Python 96.26% C 0.68% Nu 0.05% Fortran 0.01% PowerShell 0.14% Nix 0.01% Cython 2.04%

tradingview-access-management's Introduction

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. {
          "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.
    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

tradingview-access-management's People

Contributors

trendoscope-algorithms avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.