Skip to content
hokein edited this page Oct 14, 2014 · 22 revisions

The greenworks module gives you ability to access Steam APIs, a simple example:

var greenworks = require('./lib/greenworks');

if (greenworks.initAPI()) {
  console.log('Steam API has been initalized.');
} else {
  console.log('Error on initializing Steam API');
}

##References

###Greenworks.initAPI()

Returns a Boolean whether Steam APIs were successfully initialized or not.

Note: You need to launch and log in the Steam Client, and put steam_appid.txt under your app directory.

###Greenworks.getSteamId()

Returns an 'Object' represents extensive information of the current Steam user.

  • Result Object
    • accountId Integer: Steam account ID
    • staticAccountId Integer: Static steam ID
    • screenName String: Steam screen name
    • level Integer: Steam level
    • isValid Boolean: whether is a valid account
    • type Object: represents user account type
      • name String: User account type name
      • value Integer: User account type id
    • flags Object: represents describing types of user account information
      • anonymous Boolean: whether is an anonymous account
      • anonymousGameServer Boolean: whether is an anonymous game server account
      • anonymousGameServerLogin Boolean: whether is an anonymous game server account login request
      • anonymousUserBoolean: whether is an anonymous user account
      • chat Boolean: whether is a chat account
      • clan Boolean: whether is a clan account
      • consoleUser Boolean: whether is a console user(PSN) account
      • contentServer Boolean: whether is a content server account
      • gameServer Boolean: whether is a game server account
      • individual Boolean: whether is a individual account
      • gameServerPersistent Boolean: whether is a persistent game server account
      • lobby Boolean: whether is a lobby(chat) account

###Greenworks.saveTextFoFile(file_path, file_content, success_callback, [error_callback])

  • file_path String
  • file_content String
  • success_callback Function()
  • error_callback Function(err)

###Greenworks.readTextFromFile(file_path, success_callback, [error_callback])

  • file_path String
  • success_callback Function(file_content)
    • file_content String: represents the content of file_name file.
  • error_callback Function(err)

###Greenworks.saveFilesToCloud(files_path, success_callback, [error_callback])

  • files_path Array of String
  • success_callback Function()
  • error_callback Function(err)

Writes mutilple local files to Steam Cloud.

###Greenworks.isCloudEnabled()

Returns a Boolean indicates whether cloud is enabled for the current app.

###Greenworks.enableCloud(flag)

  • flag Boolean

Enables/Disables the cloud feature for the current app.

###Greenworks.getCloudQuota(success_callback, [error_callback])

  • success_callback Function(total_bytes, available_bytes)
    • total_bytes Integer: total bytes of quota
    • available_bytes Integer: available bytes of quota
  • error_callback Function(err)

###Greenworks.activateAchievement(achievement, success_callback, [error_callback])

  • achievement String
  • success_callback Function()
  • error_callback Function(err)

The achievement represents the unlocked achievement in your game.

###Greenworks.getCurrentGameLanguage()

Returns a String represents the current language from Steam specifically set for the game.

###Greenworks.getCurrentUILanguage()

Returns a String represents the current language from Steam set in UI.

###Greenworks.getCurrentGameInstallDir()

Not implement yet.

###Greenworks.getNumberOfPlayers(success_callback, [error_callback])

  • success_callback Function(num_of_players)
    • num_of_players Integer: the current number of players on Steam.
  • error_callback Function(err)

###Greenworks.fileShare(file_path, success_callback, [error_callback])

  • file_path String
  • success_calback Function(file_handle)
    • file_handle Integer: The handle that can be shared with users and features
  • error_callback Function(err)

###Greenworks.publishWorkshopFile(file_path, image_path, title, description, success_callback, [error_callback])

  • file_path String
  • image_path String
  • title String
  • description String
  • success_callback Function(publish_file_id)
    • publish_file_id Integer: represents the published file id on Steam.
  • error_callback Function(err)

Publish file_path workshop item on Steam. The files file_path and image_path need to be on Steam Cloud(Using writeTextToFile or saveFilesToCloud API) and get shared(Using Greenworks.fileShare) first.

An empty String of image_path means no image for the workshp item.

###Greenworks.updatePublishedWorkshopFile(published_file_id, file_path, image_path, title, description, success_callback, [error_callback])

  • published_file_id Integer
  • file_path String
  • image_path String
  • title String
  • description String
  • success_callback Function()
  • error_callback Function(err)

An empty String of file_path/image_path/title/description means no update of that field.

###Greenworks.ugcPublish(file_path, title, description, image_path, success_callback, [error_callback], [progress_callback])

  • file_path String
  • title String
  • description String
  • image_path String
  • success_callback Function(published_file_id)
    • published_file_id String
  • error_callback Function(err)
  • progress_callback Function(progress_msg)
    • progress_msg String: current process during publish period: Completed on saving files to Steam Cloud, Completed on sharing files.

Publishes user generated content(ugc) to Steam workshop.

###Greenworks.ugcPublishUpdate(published_file_id, file_path, title, description, image_path, success_callback, [error_callback], [progress_callback])

  • published_file_id Integer
  • file_path String
  • title String
  • description String
  • image_path String
  • success_callback Function()
  • error_callback Function(err)
  • progress_callback Function(progress_msg)
    • progress_msg String: current process during publish-update period: Completed on saving files to Steam Cloud, Completed on sharing files.

Updates published ugc.

###Greenworks.ugcGetItems(ugc_matching_type, ugc_query_type, success_callback, [error_callback])

  • ugc_matching_type greenworks.UGCMatchingType

  • ugc_query_type greenworks.UGCQueryType

  • success_callback Function(nums_of_item, items)

    • nums_of_item Integer
    • items Array of SteamUGCDetails Object
      • acceptForUse Boolean
      • banned Boolean
      • tagsTruncated Boolean
      • fileType Integer
      • result Integer
      • visibility Integer
      • score Double
      • file Integer
      • fileName String
      • fileSize Integer
      • previewFile Integer
      • previewFileSize Integer
      • steamIDOwner Integer
      • consumerAppID Integer
      • creatorAppID Integer
      • publishedFileId Integer
      • title String
      • description String
      • URL String
      • tags String
      • timeAddedToUserList Integer
      • timeCreated Integer
      • timeUpdated Integer
      • votesDown Integer
      • votesUp Integer
  • error_callback Function(err)

Clone this wiki locally