Getting an API key

QScored API usage requires authorization. You need to obtain an API key first to invoke any QScored API.

You may get your API key by clicking "Request you API key" button on Settings page after logging into your QScored account. QScored will send the key to your email address.


Upload API

For uploading a new code quality analysis, you may use the "upload" API. You need to provide the required parameters and invoke the API with your API key. If everything goes fine, your analysis report will be uploaded to the QScored.

  • Header: QScored upload API expects four parameters in the header.
    • Content-Type: As QScored expects you to pass an XML file, its value must always be 'application/xml'.
    • Username: Your registered email address on QScored.
    • Repository-link: Source code repository link (for instance, GitHub repository link). It is an optional field.
    • Authorization token: Your QScored API key.
  • Body: The body of the API call contains only one thing i.e., the source code analysis file (XML) that you would like to upload.
  • Get :You need to specify the following parameters in the Get block of the API call:
    • Project name: A project name. We expect it to be unique for your account if it is a new project. If you are uploading a new version for an existing project, specify the project name exactly same as the existing one.
    • Version number: Version number in 'w.x.y.z' format where x, y, and z are optional.
    • Open access permission: True or False. Setting it True will make the project identity and data publicly accessible; otherwise only you will be able to see the project data.

We provide an example for the upload API (Python).

    import requests
    import urllib.parse

    project_name = "My Project"
    version = 1.2.1.5
    repo_link = "https:repo.co/repo......"
    is_open_access = "True"

    file_name = "file.xml"
    user_name = "example@example.com"
    API_KEY = "34n3rn3n4irni3nikrni3nirn3nr3"

    headers = {
      'Content-Type': 'application/xml',
      'username': user_name,
      'repository-link': repo_link,
      'Authorization': 'Token ' + API_KEY,
      }
    getVars = {
      'version': version,
      'project_name': project_name,
      'is_open_access': is_open_access,
      }
    url = "https://qscored.com/api/upload/" + file_name + "/" + urllib.parse.urlencode(getVars)
    with open(xml_file_path, 'rb') as fp:
      response = requests.put(url=url, files={'file': fp, }, headers = headers,)
    

Search APIs

QScored offers two search APIs search repositories based on search parameters.

Search quality by quality parameters:

The first search API 'search_project_by_quality' allows users to search projects based on their quality ranking. One may specify filters language and LOC range to obtain a list of projects that satisfy the criteria sorted in the order of their quality ranking. The API returns the first 20 projects that satisfy the specified criteria; for the next 20 projects, the API offers another parameter start_index, that could be used to get the successive sets of projects.

    import requests
    
    min_loc = "232"
    max_loc = "234567"
    lang = 'cs'
    start_index = 10
    
    user_name = "example@example.com"
    API_KEY = "34n3rn3n4irni3nikrni3nirn3nr3"
    headers = {
       'Content-Type': 'application/x-www-form-urlencoded',
       'username': user_name,
       'Authorization': 'Token ' + API_KEY,
      }
    
    data = {
       'min_loc': min_loc,
       'max_loc': max_loc,
       'lang': lang,
       'start_index': '100',
      }
    
    url = "https://qscored.com/api/search_project_by_quality/"
    
    response = requests.post(url=url, data=data, headers=headers, )
    print(response.content)
            


Search projects:

The second API 'search_project' returns the metadata about the searched projects. The API takes project name and repository link as inputs. Both of the search APIs returns a list of project metadata containing project name and unique id, repository link, LOC, programming language, as well as quality rank and score.

    import requests
    
    project_name = "Pantry3"
    repo_link = ""
    lang = ""
    
    file_name = "text.xml"
    start_index = 10
    user_name = "example@example.com"
    API_KEY = "token"
    
    headers = {
       'Content-Type': 'application/x-www-form-urlencoded',
       'username': user_name,
       'Authorization': 'Token ' + API_KEY,
      }
    
    data = {
       'project_name': project_name,
       'repo_link': repo_link,
       'lang': lang,
       'start_index': start_index,
      }
    
    url = "https://qscored.com/api/search_project/"
    
    response = requests.post(url=url, data=data, headers=headers, )
    print(response.content)

Delete API

QScored also offer you an API so as to delete a project or a specific version of a project

Delete a project

Here is a example to delete a complete project.

    import requests
    project_name = "project_name"
    all_flag = "True"
    
    file_name = "text.xml"
    start_index = 10
    user_name = "vishvajeet10gfs@gmail.com"
    API_KEY = "541c15bc549e0ddbf0d1aa30c00afa2f5954eff9"
    
    headers = {
        'Content-Type': 'application/x-www-form-urlencoded',
        'username': user_name,
        'Authorization': 'Token ' + API_KEY,
    }
    data = {
        'project_name': project_name,
        'all_flag': all_flag,
    }
    
    url = "https://qscored.com/api/delete/"
    
    
    response = requests.post(url=url, data=data, headers=headers, )
    print(response.content)
    
Delete a version

Here is a example to a delete a particular version of a project.

    import requests
    project_name = "small"
    version = "1.1"
    
    file_name = "text.xml"
    start_index = 10
    user_name = "vishvajeet10gfs@gmail.com"
    API_KEY = "541c15bc549e0ddbf0d1aa30c00afa2f5954eff9"
    
    headers = {
        'Content-Type': 'application/x-www-form-urlencoded',
        'username': user_name,
        'Authorization': 'Token ' + API_KEY,
    }
    data = {
        'project_name': project_name,
        'version': version,
    }
    
    url = "https://qscored.com/api/delete/"
    
    response = requests.post(url=url, data=data, headers=headers, )
    print(response.content)