Topcoder Skill Builder Competition | Golang | Solar System data: Retrieval

Key Information

Status: ‌Cancelled client request

Challenge Overview

Challenge Overview

Challenge Banner


This is the MEDIUM 500 Points Competition

With recovery completed, all eyes are on you now to get a data retrieval system up and running.

Your task for this level is to continue the previous solution. Now that there’s data in the database you need to write Rest APIs to expose the data so the scientists can go back to their research and the space ships can take off again.

Solving this problem you will learn:

  • To use the Gin framework to write Rest APIs
  • To structure code and build routes for the retrieval APIs
  • To query database using Go
  • To return paginated results
  • To handle data validation when serving requests

Learning Material:

What do you need to do next?


Continue using your submission from EASY-250; or atleast use the provided sample submission as the base project. The automated tester will call the "POST /api/v1/recover" endpoint to seed data.

Technology Stack

  • Go
  • PostgreSQL
  • go-pg
  • Gin framework


Search bodies

Method: GET URL: /api/v1/bodies?type=TYPE&orderBy=ATTRIBUTE&size=SIZE&page=PAGE


  • If type is specified, the bodies should be filtered by the specified type, otherwise response should include bodies of all types
  • If orderBy is specified, the list should be sorted in ascending order by the attribute ATTRIBUTE. Acceptable values of ATTRIBUTE are: name, type and moons.
  • If size is specified, the response should include at most size bodies. Otherwise only 10 records should be returned. Acceptable values of size are positive integers only.
  • If page is specified, the response should contain records that are offset by (page - 1 ) * size; page should start from 1.

Response: Response should return HTTP status code 200 and be a JSON object. Here's an example:

  "total": "10",
  "currentPage": "1",
  "data": [
      "id": "ID",
      "type": "TYPE",
      "name": "NAME",
      "description": "DESCRIPTION",
      "moons": "NUMBER OF MOONS"


Any error should return HTTP status code 400 and be a JSON object in the following format

{ "message": "ERROR MESSAGE" }

  • If attribute is invalid, message should be “Invalid Attribute” (without quotes)
  • If page is invalid, message should be “Invalid Page” (without quotes)
  • If size is invalid, message should be “Invalid Size” (without quotes)

Get a planetary bodies details along with physical characteristics and orbital parameters.

Method: GET URL: /api/v1/bodies/:id

Response: Response should return HTTP status code 200 and be a JSON object formatted as follows

  "id": "ID",
  "type": "TYPE",
  "name": "NAME",
  "description": "DESCRIPTION",
  "moons": "NUMBER OF MOONS",
  "density": "DENSITY",
  "gravity": "GRAVITY",
  "mass": {
    "value": "MASS VALUE",
    "exp": "MASS EXPONENT"
  "volume": {
    "value": "VOLUME VALUE",
    "exp": "VOLUME EXPONENT"
  "sideralOrbit": "SIDERAL ORBIT",
  "sideralRotation": "SIDERAL ROTATION"


If the id is invalid, the response should return HTTP status code 404 with the following message

  “message”: “No body with id ID found”


The automated grader will invoke the endpoints from the spec with different configurations and test for 200, 400 and 404 response codes in addition to checking for correctness of returned data. Each response will either get a 0 or a 1. The final score will be (correct responses/total queries) * 100

Submission Deliverables

You must follow this submission folder structure and the "Dockerfile" in the sample submission so our automated test process can process your scoring:

  • Create a folder with “code” as the folder name then zip.
  • Inside the “code” folder, there needs to be a file named Dockerfile. This is the docker file used to build the user’s submission. Refer to the provided Docker file in Sample Submission for each level.
  • Zip that “code” folder and submit to the challenge.
  • After you submit - you will be able to check your score and logs on the challenge leaderboard and submission-review app respectively.
  • In case you receive a score of -1, please look at the logs and go through the sample submission and submission guidelines once to see if you are doing things correctly.

Topcoder Go Skill Builder Problems


2022 Topcoder(R) Open


Final Review:

Community Review Board


User Sign-Off


ID: 30196407