Question: what is the  capital city of libya which  Barbary pirates was also based primarily in 

Context articles: Barbary pirates
Barbary Wars
Mulai Ahmed er Raisuni
French corsairs
The Pirate City: An Algerine Tale
Tripoli
USS President (1800)
Joseph Pitts (author)
USS Constellation (1797)
USS Chippewa (1815)

The Barbary pirates, sometimes called Barbary corsairs or Ottoman corsairs, were pirates and privateers who operated from North Africa, based primarily in the ports of Salé, Rabat, Algiers, Tunis, and Tripoli.
 This area was known in Europe as the Barbary Coast, a term derived from the name of its Berber inhabitants.
 Their predation extended throughout the Mediterranean, south along West Africa's Atlantic seaboard and even South America, and into the North Atlantic as far north as Iceland, but they primarily operated in the western Mediterranean.
 In addition to seizing ships, they engaged in "Razzias", raids on European coastal towns and villages, mainly in Italy, France, Spain, and Portugal, but also in the British Isles, the Netherlands and as far away as Iceland.
 The main purpose of their attacks was to capture Christian slaves for the Ottoman slave trade as well as the general Muslim slavery market in North Africa and the Middle East.
The Barbary Wars were a series of conflicts that culminated in two wars fought at different times over the same reasons between the United States, Sweden, and the Barbary states (the "de jure" possessions of the Ottoman Empire, but "de facto" independent, Tunis, Algiers, and Tripoli) of North Africa in the late 18th and early 19th centuries.
 The Swedes had been at war with the Tripolitans since 1800; they were eventually joined by the Americans.
 At issue was the Barbary pirates' demand for tribute from American merchant vessels in the Mediterranean Sea.
 If ships of a given country failed to pay, pirates would attack the ship and take their goods, and often enslave crew members or hold them for ransom.
 When Thomas Jefferson became President of the United States in March 1801, he refused to pay tribute and sent a United States Naval fleet to the Mediterranean; the fleet bombarded various fortified pirate cities in present-day Libya, Tunisia, and Algeria, ultimately extracting concessions of fair passage from their rulers.
 James Madison, Jefferson's successor, directed military forces for the second war in 1815, shortly after the conclusion of the War of 1812 against the British.
Mulai Ahmed er Raisuni (Arabic: "مولاي أحمد الريسوني", known as Raisuli to most English speakers, also Raissoulli, Rais Uli, and Raysuni) (b. 1871, Zinat, Tétouan – d. April 1925, Tamasint, Al Hoceima) was a Sharif (descendant of the Islamic prophet Muhammad), and a leader of the Jebala tribal confederacy in Morocco at the turn of the 20th Century.
 While regarded by foreigners and the Moroccan government as a brigand, some Moroccans, especially among the Jebala, considered him a heroic figure, fighting a repressive, corrupt government, while others considered him a thief.
 Historian David S. Woolman referred to Raisuni as "a combination Robin Hood, feudal baron, and tyrannical bandit."
 He was considered by many as "The last of the Barbary Pirates" though Barbary Coast piracy had ended by the middle of the 19th century.
 On the other hand, according to Douglas Porch, an American historian, Raisuni was part of the rule rather than the exception in that every successful Moroccan politician at the time combined villainy with sainthood.
 He died in April 1925 after having been captured and imprisoned by his rival Abd el Krim.
Corsairs (French: "corsaire" ) were privateers, authorized to conduct raids on shipping of a nation at war with France, on behalf of the French crown.
 Seized vessels and cargo were sold at auction, with the corsair captain entitled to a portion of the proceeds.
 Although not French Navy personnel, corsairs were considered legitimate combatants in France (and allied nations), provided the commanding officer of the vessel was in possession of a valid Letter of Marque ("Lettre de Marque" or "Lettre de Course", the latter giving "corsairs" their name), and the officers and crew conducted themselves according to contemporary admiralty law.
 By acting on behalf of the French Crown, if captured by the enemy, they could in principle claim treatment as prisoners of war, instead of being considered pirates.
 Because corsairs gained a swashbuckling reputation, the word "corsair" is also used generically as a more romantic or flamboyant way of referring to privateers, or even to pirates.
 The Barbary pirates of North Africa as well as Ottomans were sometimes called "Turkish corsairs".
The Pirate City: An Algerine Tale was written by R. M. Ballantyne and was published in 1874.
 It is a work of juvenile fiction and adventure fiction which follows the Rimini family.
 The Riminis disembark from Sicily on a trading expedition only to be captured by Barbary Pirates and taken to the pirate city of Algiers, which is the present day capital of Algeria.
Tripoli (Arabic: طرابلس‎ ‎ , "Ṭarābulus" ; Berber: "Ṭrables") is the capital city and the largest city of Libya.
 Tripoli, with its metropolitan area, has a population of about 1.1 million people.
 The city is located in the northwestern part of Libya on the edge of the desert, on a point of rocky land projecting into the Mediterranean and forming a bay.
USS "President" was a wooden-hulled, three-masted heavy frigate of the United States Navy, nominally rated at 44 guns.
 George Washington named her to reflect a principle of the United States Constitution.
 She was launched in April 1800 from a shipyard in New York City.
 "President" was one of the original six frigates whose construction the Naval Act of 1794 had authorized, and she was the last to be completed.
 Joshua Humphreys designed these frigates to be the young Navy's capital ships, and so "President" and her sisters were larger and more heavily armed and built than standard frigates of the period.
 Forman Cheeseman, and later Christian Bergh were in charge of her construction.
 Her first duties with the newly formed United States Navy were to provide protection for American merchant shipping during the Quasi War with France and to engage in a punitive expedition against the Barbary pirates in the First Barbary War.
Joseph Pitts (1663–1735?)
 was an Englishman who was taken into slavery by Barbary pirates from Algeria in 1678 at the age of fourteen or fifteen.
 Little is known about Pitts aside from what is revealed in his narrative concerning his time held captive in Northern Africa, during which time he went through three masters ranging widely in their cruelty towards him over the course of more than fifteen years, with whom he travelled to Cairo and Alexandria.
 Though he escaped between the years 1693 and 1694, it was not until 1704 that Pitts first published his account.
 Pitts's "A True and Faithful Account of the Religion and Manners of the Mohammetans, with an Account of the Author's Being Taken Captive" includes descriptions of his capture and captivity, including some of the first English descriptions of Islamic rituals.
 Converting to the religion while a slave, Pitts was the first Englishman to record the proceedings of the hajj, one of the five pillars of Islam.
 Pitts also describes the people of seventeenth-century North Africa (whom he calls Turks or Mohammetans) in detail, providing particulars on their manner of eating and dressing, the customs of their religion and marriage, and their economic and slave systems.
 Though its accuracy is debatable, Pitts’s narrative was the first and most detailed description of the religion of Islam and the manners of Muslims written by a European during the seventeenth century.
USS "Constellation" was a nominally rated 38-gun wooden-hulled, three-masted heavy frigate of the United States Navy.
 She was named by George Washington to reflect a principle of the United States Constitution.
 She was built under the direction of David Stodder at his naval shipyard on Harris Creek in Baltimore's Fell's Point maritime community, and she was launched on 7 September 1797.
 She was one of the original six frigates whose construction the Naval Act of 1794 had authorized.
 Joshua Humphreys designed these frigates to be the young Navy's capital ships, and so "Constellation" and her sisters were larger and more heavily armed and built than standard frigates of the period.
 Her first duties with the newly formed US Navy were to provide protection for American merchant shipping during the Quasi-War with France and to defeat the Barbary pirates in the First Barbary War.
USS "Chippewa" was a brig built in 1815 at Warren, Rhode Island, under the direction of Commodore Oliver Perry, and sent to New York City to be outfitted and manned.
 "Chippewa" sailed from Boston, Massachusetts, 3 July 1815, with Lieutenant George C. Read in command, as a part of a squadron under the command of Commodore William Bainbridge.
 It was intended to go to the Mediterranean for use against the Barbary pirates based in North Africa.