Skip to content

SpyMinerX/wombo-dream-api

 
 

Repository files navigation

wombo-dream-api License NPM version NPM downloads

Unofficial API for Wombo Dream

❤ Feel free to contribute to the project ❤

Used by

Upcomming features

  • NFT minting
  • change of password/username/email/profile picture
  • ability to browse other users' profiles

Changelog

0.1.6

  • Refactoring
  • Documentation updated
  • API testing

0.1.5

  • Can now fetch tasks shop url
  • Can now save, fetch, fetch all and delete tasks in the gallery

0.1.4-fix

  • Throw error when task generation fails
  • uploaded images MUST be jpg/jpeg

0.1.4

Installation

node.js

npm install wombo-dream-api

Please read the Documentation to learn more about the api.

Example

const { buildDefaultInstance } = require('wombo-dream-api');
const fs = require('fs');

(async () => {
	try {
		const credentials = {
			email: 'mysuperemail@gmail.com',
			password: 'mypassword',
		};

		// signin is automatically done when you interract with the api if you pass credentials
		const wombo = buildDefaultInstance(credentials);

		// if you want to sign up as new user:
		// await wombo.authentifier.signUp(credentials);

		// fetch all styles
		const styles = await wombo.fetchStyles();
		console.log(styles.map((style) => `[${style.id}] ${style.name}`));

		// upload image [ONLY JPEG SUPPORTED]
		const uploadedImage = await wombo.uploadImage(
			fs.readFileSync('./image.jpeg')
		);

		// generate picture from image
		const generatedTask = await wombo.generatePicture(
			'mountain',
			styles[0].id,
			(taskInProgress) => {
				console.log(
					`[${taskInProgress.id}]: ${taskInProgress.state} | step: ${taskInProgress.photo_url_list.length}`
				);
			},
			{ mediastore_id: uploadedImage.id, weight: 'HIGH' }
		);

		console.log(
			`[${generatedTask.id}]: ${generatedTask.state} | final url: ${generatedTask.result?.final}`
		);

		// to interract with the gallery, YOU NEED TO HAVE A USERNAME!
		// if you just created the account and it doesn't have a username, set it with:
		// await wombo.setUsername('myusername');

		// save an image in the gallery
		const savedTask = await wombo.saveTaskToGallery(
			generatedTask.id,
			'my wonderful creation',
			true,
			true
		);

		console.log('image saved!');

		// obtain gallery tasks
		const galleryTasks = await wombo.fetchGalleryTasks();

		console.log(galleryTasks);
	} catch (error) {
		console.error(error);
	}
})();

More examples can be found in the Documentation

License

MIT

About

Unofficial API for Wombo Dream

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 99.4%
  • JavaScript 0.6%